Advanced Printing

There are several advanced options available when printing PDF documents. The following examples illustrate selectively printing PDF Content using page ranges, multiple pages per sheet, a specified area within a PDF document, and portfolio printing. The following examples illustrate these advance printing topics.

Print Page Ranges

In this example you add a range of pages from different PDFs to a print job. When printing the PDF, the output for the first job is pages one through three, the second job pages three and four, and the third job pages two through five.

PrintJob printJob = new PrintJob(Printer.Default);
printJob.Pages.Add(pdfFilePath, 1, 3);
printJob.Pages.Add(pdfFilePath, 3, 2);
printJob.Pages.Add(pdfFilePath, 2, 4);
Dim printjob As PrintJob = New PrintJob(Printer.Default)
printJob.Pages.Add(pdfFilePath, 1, 3)
printjob.Pages.Add(pdfFilePath, 3, 2)
printjob.Pages.Add(pdfFilePath, 2, 4)

Print Multiple Pages per Sheet

This example demonstrates how to print multiple PDF pages to a single sheet of paper where the pages are printed in four rows and two columns.

PrintJob printJob = new PrintJob(Printer.Default, pdfFilePath, 1, 4);
MultipagePageScaling multipagePageScaling = new MultipagePageScaling(4, 2);
multipagePageScaling.Border = new Border(System.Drawing.Color.Green, 2);
multipagePageScaling.Margin = new ceTe.DynamicPDF.Printing.Margin(5, 5, 5, 5);
multipagePageScaling.Spacing = new Spacing(2, 2);
multipagePageScaling.UniformScaling = true;
printJob.PrintOptions.Scaling = multipagePageScaling;
Dim printJob As New PrintJob(Printer.Default, pdfFilePath, 1, 4)
Dim multipagePageScaling As New MultipagePageScaling(4, 2)
multipagePageScaling.Border = New Border(System.Drawing.Color.Green, 2)
multipagePageScaling.Margin = New ceTe.DynamicPDF.Printing.Margin(5, 5, 5, 5)
multipagePageScaling.Spacing = New Spacing(2, 2)
multipagePageScaling.UniformScaling = True
printJob.PrintOptions.Scaling = multipagePageScaling

Print Specified Area of a PDF Page

You can also print a specific area of a PDF page, as the following example demonstrates.

InputPdf pdf = new InputPdf(pdfFilePath);
PrintJob printJob = new PrintJob(Printer.Default);
//Specify print area for the second & third pages and add them to print job.
System.Drawing.Rectangle printArea = new System.Drawing.Rectangle(0, 0, 600, 400);
printJob.Pages.Add(pdf, printArea, 2, 2);
Dim pdf As InputPdf = New InputPdf(pdfFilePath)
Dim printJob As PrintJob = New PrintJob(Printer.Default)
'Specify print area for the second & third pages and add them to print job.
Dim printArea As System.Drawing.Rectangle = New System.Drawing.Rectangle(0, 0, 600, 400)
printJob.Pages.Add(pdf, printArea, 2, 2)

Print PDFs from PDF Portfolio

This final example demonstrates how to retrieve and print PDF attachments from a PDF portfolio. Non-PDF attachments are not retrieved and the TryGetPdf() method returns null.

InputPdf portfolioPDF = new InputPdf(pdfFilePath);
PrintJob printJob = new PrintJob(Printer.Default);
Attachment[] files = portfolioPDF.Attachments;
foreach (Attachment file in files)
   InputPdf pdfAttachment = file.TryGetPdf();
   if (pdfAttachment != null)
if (printJob.Pages.Count > 0)
Dim portfolioPDF As InputPdf = New InputPdf(pdfFilePath)
Dim printJob As PrintJob = New PrintJob(Printer.Default)
Dim files As Attachment() = portfolioPDF.Attachments
For Each file As Attachment In files
   Dim pdfAttachment As InputPdf = file.TryGetPdf()
   If pdfAttachment IsNot Nothing Then
   End If
If printJob.Pages.Count > 0 Then
End If 

In this topic