Method Merge
Merge(IEnumerable<Attachment>)
Merges multiple PDF attachments into a single attachment containing all pages in order.
public static Attachment Merge(IEnumerable<Attachment> sources)
Parameters
sourcesIEnumerable<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
sourcesisnull.- 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
inputPathsIEnumerable<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
inputPathsisnull.- ArgumentException
Thrown when no input paths are provided.
- FileNotFoundException
Thrown when any input file does not exist.