PDF Input Sources
The InputPdf class represents a PDF document whose pages can be added to a PrintJob. Use it when you need to load a PDF, inspect its document information, or work with individual pages before printing.
An InputPdf object can be initialized from either a file path or a byte array, with optional support for password-protected PDFs. After the object is created, you can add the entire PDF to a PrintJob, or add selected pages individually using the PrintJob.Pages.Add method.
An InputPdf can be added to a PrintJob through its constructor or by accessing specific pages and adding the selected pages to a print job's pages.
Constructors
The InputPdf class provides constructors for initializing a PDF document using a file path or byte array, with optional password support.
Properties
The InputPdf class provides properties for accessing PDF document metadata and content, including the document title, author, subject, keywords, producer, attachments, and the collection of pages contained within the PDF document.
Methods
The InputPdf class provides methods for releasing resources and includes standard inherited .NET object methods such as equality comparison, type information, hash generation, and string representation.
Password-Protected PDFs
The InputPdf class also supports opening password-protected PDF documents by specifying the password in the constructor (see Printing Secure PDFs)
Printing Entire Document
The following example loads a PDF into an InputPdf instance, prints a few of the document's properties, and then prints the PDF.
InputPdf inputPdf = new InputPdf(Util.GetPath("Resources/DocumentA.pdf"), "password");
Console.WriteLine("==== properties ====");
Console.WriteLine("Author: " + inputPdf.Author);
Console.WriteLine("Keywords: " + inputPdf.Keywords);
Console.WriteLine("Title: " + inputPdf.Title);
PrintJob printJob = new PrintJob(Printer.Default, inputPdf);
printJob.Print();
Dim inputPdf As New InputPdf(Util.GetPath("Resources/DocumentA.pdf"), "password")
Console.WriteLine("==== properties ====")
Console.WriteLine("Author: " & inputPdf.Author)
Console.WriteLine("Keywords: " & inputPdf.Keywords)
Console.WriteLine("Title: " & inputPdf.Title)
Dim printJob As New PrintJob(Printer.Default, inputPdf)
printJob.Print()
[InputSourceExample.cs](https://github.com/DynamicPDF/print-manager-dotnet-core/blob/master/print-manager-dotnet-core-cs/InputSourceExample.cs){#gitlink-id target=_blank}
[InputSourceExample.vb](https://github.com/DynamicPDF/print-manager-dotnet-core/blob/master/print-manager-dotnet-core-vb/InputSourceExample.vb){#gitlink-id target=_blank}
Printing Select Pages
An InputPdf has a Pages property that contains a PDF's individual pages as a collection. Each page is an InputPdfPage instance, which has a Height and Width property.
You can also print select pages using several of the PrintJob class's constructor overloads (see Print Page Ranges )
PrintJob printJob = new PrintJob(Printer.Default);
InputPdf inputPdf = new InputPdf(Util.GetPath("Resources/DocumentA.pdf"));
InputPdfPage firstPage = inputPdf.Pages[0];
InputPdfPage fourthPage = inputPdf.Pages[3];
printJob.Pages.Add(firstPage);
printJob.Pages.Add(fourthPage);
printJob.Print();
Dim printJob As New PrintJob(Printer.Default)
Dim inputPdf As New InputPdf(Util.GetPath("Resources/DocumentA.pdf"))
Dim firstPage As InputPdfPage = inputPdf.Pages(0)
Dim fourthPage As InputPdfPage = inputPdf.Pages(3)
printJob.Pages.Add(firstPage)
printJob.Pages.Add(fourthPage)
printJob.Print()
[InputPagesExample.cs](https://github.com/DynamicPDF/print-manager-dotnet-core/blob/master/print-manager-dotnet-core-cs/InputPagesExample.cs){#gitlink-id target=_blank}
[InputPagesExample.vb](https://github.com/DynamicPDF/print-manager-dotnet-core/blob/master/print-manager-dotnet-core-vb/InputPagesExample.vb){#gitlink-id target=_blank}
Note that what is actually occurring is that the PrintJobPageList.Add method of the PrintJobPageList class is being used to add an input PDF while limiting which pages are included in the print job.