PDF Command Line Tools

Download Free Trial
Buy Now
Read Manual
Blog
Resellers
Custom Development
News Archive
Links
Free PDF Library
Command Line Manual (HTML)

Coherent PDF .NET API Usage Examples

Back to main page

Here are some examples of the Coherent PDF .NET API in action. For more instructions, see the Full PDF Manual.

//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 pdfs = new List {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();
}

In C#, read the file hello.pdf and triplicate it, writing to merged.pdf

' Merge example
imports System
imports System.Collections.Generic
imports CoherentGraphics

' Initialise cpdf
Cpdf.startup()

' We will take the input hello.pdf and repeat it three times
Using mergepdf As Cpdf.Pdf = Cpdf.fromFile("hello.pdf", "")
  ' The list of PDFs to merge
  Dim pdfs As List(Of Cpdf.Pdf) =
    new List(Of Cpdf.Pdf)({mergepdf, mergepdf, mergepdf})

  ' Merge them
  Dim merged As Cpdf.Pdf = Cpdf.mergeSimple(pdfs)

  ' Write output
  Cpdf.toFile(merged, "merged.pdf", false, false)

  ' Dispose of merged PDF
  merged.Dispose()
End Using

The same example, in VB.NET.