Table of Contents

Method Merge

Namespace
LMKit.Document.Pdf
Assembly
LM-Kit.NET.dll

Merge(IEnumerable<Attachment>)

Merges multiple PDF attachments into a single attachment containing all pages in order.

public static Attachment Merge(IEnumerable<Attachment> sources)

Parameters

sources IEnumerable<Attachment>

The source PDF attachments to merge.

Returns

Attachment

A new Attachment containing all pages from all sources.

Examples

using System;
using System.Collections.Generic;
using LMKit.Data;
using LMKit.Document;

// Load individual PDFs
var cover = new Attachment("cover.pdf");
var body = new Attachment("body.pdf");
var appendix = new Attachment("appendix.pdf");

// Merge into a single document
Attachment merged = PdfMerger.Merge(new[] { cover, body, appendix });
Console.WriteLine($"Merged PDF has {merged.PageCount} pages");

Exceptions

ArgumentNullException

Thrown when sources is null.

ArgumentException

Thrown when no sources are provided or when any source is not a PDF.

Merge(IEnumerable<string>)

Merges multiple PDF files into a single attachment containing all pages in order.

public static Attachment Merge(IEnumerable<string> inputPaths)

Parameters

inputPaths IEnumerable<string>

Paths to the source PDF files.

Returns

Attachment

A new Attachment containing all pages from all sources.

Examples

using System;
using LMKit.Data;
using LMKit.Document;

// Merge PDF files into an in-memory attachment
Attachment merged = PdfMerger.Merge(
    new[] { "part1.pdf", "part2.pdf", "part3.pdf" });
Console.WriteLine($"Merged PDF has {merged.PageCount} pages");

Exceptions

ArgumentNullException

Thrown when inputPaths is null.

ArgumentException

Thrown when no input paths are provided.

FileNotFoundException

Thrown when any input file does not exist.