|
Coherent PDF Java API Usage ExampleHere are some examples of the Coherent PDF .NET API in action. For more instructions, see the Full PDF Manual. //Merge example import com.coherentpdf.Jcpdf public static void main(String[] args) { // Initialise cpdf Jcpdf jcpdf = new Jcpdf(); try { jcpdf.startup(); } catch (Jcpdf.CpdfError e) { System.out.println("Error during cpdf startup"); } // We will take the input hello.pdf and repeat it three times try (Jcpdf.Pdf mergepdf = jcpdf.fromFile("hello.pdf", "")) { // The array of PDFs to merge Jcpdf.Pdf[] pdfs = {mergepdf, mergepdf, mergepdf}; // Merge them Jcpdf.Pdf merged = jcpdf.mergeSimple(pdfs); // Write output jcpdf.toFile(merged, "merged.pdf", false, false); // Dispose of merged PDF merged.close(); } catch (Jcpdf.CpdfError e) { System.out.println("Error during cpdf operation"); } } In Java, read the file hello.pdf and triplicate it, writing to merged.pdf |