This program loads a file hello.pdf from disk and writes out a document with the original included three times.
//Merge example using System; using System.Collections.Generic; using CoherentGraphics; // Initialise cpdf Cpdf.startup(); // We will take the input hello.pdf and repeat it three times using (Cpdf.Pdf mergepdf = Cpdf.fromFile("hello.pdf", "")) { // The list of PDFs to merge List<Cpdf.Pdf> pdfs = new List<Cpdf.Pdf> {mergepdf, mergepdf, mergepdf}; // Merge them Cpdf.Pdf merged = Cpdf.mergeSimple(pdfs); // Write output Cpdf.toFile(merged, "merged.pdf", false, false); // Dispose of merged PDF merged.Dispose(); }
Note the use of using and Dispose() to ensure the PDFs are thrown away when no longer required.