Getting Started with PDF Merge for .NET |
Overview |
The PDF merge for .NET can be used in any type of application to merge PDF documents, images and text. The downloaded archive contains the development libraries for .NET and a ready to use console application in the sample Samples folder. The source code for the command line tool is also available in the Samples\Src folder. |
PDF Merge Development Library |
The PDF Merge develoment library 'wnvpdfmerge.dll'
is managed assembly that can be linked into any .NET application,
either Win32 and console applications or ASP.NET web sites. The interface is
very easy to be understood and used. The main class in the assembly is PDFMerge.
An instance of this class can be constructed by specifying the merged document options
as an instance of the PDFDocumentOptions class or using the default document
options (normal compression, A4 page size and portrait orientation). If you need
to change any of these settings you have to pass a PDFDocumentOptions object
to the PDFMerge constructor. For a complete reference of the assembly classes
and methods see the assembly reference documention in Help.chm
document. First you have to create an instance of the PDFMerge class and then append elements to the merged document one by one. The PDFMerge class offers interfaces to append PDF files, PDF Streams, Image files, Image objects, Empty pages. There is an Append method for each of these elements. Each element appears in the merged document starting on a new page in the order you appended them to the document. After you have added the merge elements you simply call the RenderMergedPDFDocument() to get in memory representation of the PDF document or SaveMergedPDFToFile() to save the generated document in a specified disk file. Below is a simple code sample taken from the command line utility. |
1: PdfDocumentOptions pdfDocumentOptions = new PdfDocumentOptions(); 2:
3: pdfDocumentOptions.PdfCompressionLevel = PDFCompressionLevel.Normal;
4: pdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
5: pdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Portrait;
6:
7: PDFMerge pdfMerge = new PDFMerge(pdfDocumentOptions); 8:
9: pdfMerge.AppendPDFFile(pdfFilePath);
10: pdfMerge.AppendImageFile(imageFilePath);
11:
12: pdfMerge.AppendEmptyPage();
13:
14: pdfMerge.SaveMergedPDFToFile(outFile);
15:
|
PDF Merge Command Line Tool |
The PDF Merge Command Line Tool is a simple application constructed based
on the development libraries. It is also a ready to use application in case you
don't need to build your own application. The command line syntax is: mergepdf.exe {[/pdf:pdf_file] | [/emptypage] | [/image:img_file]}+ [/pagesize:(A4|A3|A2|A1|A0)] [/compression:(NoCompression|Normal|Best)] [/orientation:(Portrait|Landscape)] /out:out_file In simple terms this syntax means that you can specify the pdf files and image files in any order. The resulted merged document is specified by the out:/ argument. The full path of the source files must be specified in the arguments list. If the file path contains spaces you should quote the file name (e.g /pdf:"C:\My Documents\MyPdfFile.pdf"). Beside the elements to be merged you can also specify the resulted document options like compression level, page orientation and page size. Command line example: mergepdf.exe /pdf:"C:\Report.pdf" /emptypage /image:"C:\Image.Jpeg" /out:MergedDocument2.pdf /compression:Normal /orientation:Landscape |
Licensing |
The LicenseKey property of the PDFMerge class should be set with the string you have received after the product purchase. |