Class PdfPrintDocument
Provides advanced control over printing PDF documents to physical printers. Extends System.Drawing.Printing.PrintDocument for full Windows print integration.
For simple printing, use
Example - Advanced printing with dialog:
using System.Drawing.Printing;
using System.Windows.Forms;
var pdf = PdfDocument.FromFile("report.pdf");
var settings = new PdfPrintSettings();
var printerSettings = new PrinterSettings();
var controller = new StandardPrintController();
var printDoc = new PdfPrintDocument(pdf, settings, printerSettings, controller);
// Show print dialog:
var dialog = new PrintDialog { Document = printDoc };
if (dialog.ShowDialog() == DialogResult.OK)
{
printDoc.Print();
}
// Or print preview:
var preview = new PrintPreviewDialog { Document = printDoc };
preview.ShowDialog();
Inheritance
Namespace: IronPdf.PrintDoc
Assembly: IronPdf.dll
Syntax
public class PdfPrintDocument : PrintDocument
PDF printing in IronPDF is handled through PdfPrintDocument. It represents advanced control over printing PDF documents to physical printers.
PdfPrintDocument matters when an application needs to configure or invoke PDF printing from C# code. The class encapsulates the related options and behavior in a single object that is set up once and reused across render or processing calls. Typical scenarios include batch generation pipelines, templated document workflows, and integration with existing C# document services.
To use PdfPrintDocument, instantiate or obtain it from the relevant entry point in the IronPDF C# API. Key properties include FlattenDocument. Assign options or invoke methods on the instance to configure or perform the operation. The create forms covers typical usage in C# end to end.
using IronPdf;
// Obtain PdfPrintDocument from the relevant entry point in the IronPDF API
void Configure(PdfPrintDocument instance)
{
var current = instance.FlattenDocument;
instance.OnBeforePrintPage();
}For the broader workflow, see the edit forms guide in the IronPDF C# documentation. For broader context, the PDF printing portion of the IronPDF C# API contains related types that work with PdfPrintDocument directly. PdfPrintDocument instances inherit additional members from PrintDocument that may be relevant in advanced scenarios. In application code, treat PdfPrintDocument as a configured object that is constructed once and reused across operations rather than instantiated per call. Configuration is generally idempotent: assigning the same property value twice has the same effect as assigning it once. For diagnostic purposes, inspect the relevant PdfPrintDocument property after each operation to confirm the configured state. See the constructors, properties, and methods tables below for the complete API surface of PdfPrintDocument. Application code typically obtains or instantiates a single PdfPrintDocument and shares it across multiple IronPDF operations rather than recreating it per call.
Constructors
PdfPrintDocument(PdfDocument, PdfPrintSettings, PrinterSettings, PrintController)
Initializes a new instance of the System.Drawing.Printing.PrintDocument class.
Declaration
public PdfPrintDocument(PdfDocument pdfDocument, PdfPrintSettings settings, PrinterSettings printerSettings, PrintController printController)
Parameters
| Type | Name | Description |
|---|---|---|
| PdfDocument | pdfDocument | An PdfDocument of document. |
| PdfPrintSettings | settings | A PdfPrintSettings that configures the print document. |
| System.Drawing.Printing.PrinterSettings | printerSettings | A System.Drawing.Printing.PrinterSettings that specifies where and how the document is printed. |
| System.Drawing.Printing.PrintController | printController | The System.Drawing.Printing.PrintController that guides the printing process. |
Properties
FlattenDocument
Flatten document before rendering - useful for displaying form field values of a PDF
Declaration
public bool FlattenDocument { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Methods
OnBeforePrintPage(PrintPageEventArgs)
Represents the method that will handle the System.Drawing.Printing.PrintDocument.PrintPage
event of a System.Drawing.Printing.PrintDocument.
Declaration
protected virtual void OnBeforePrintPage(PrintPageEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.Printing.PrintPageEventArgs | e | System.Drawing.Printing.PrintPageEventArgs that contains the event data. |
OnBeforeQueryPageSettings(QueryPageSettingsEventArgs)
Represents the method that handles the System.Drawing.Printing.PrintDocument.QueryPageSettings
event of a System.Drawing.Printing.PrintDocument.
Declaration
protected virtual void OnBeforeQueryPageSettings(QueryPageSettingsEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.Printing.QueryPageSettingsEventArgs | e | A System.Drawing.Printing.QueryPageSettingsEventArgs that contains the event data. |
OnBeginPrint(PrintEventArgs)
Raises the System.Drawing.Printing.PrintDocument.BeginPrint event. It is called
after the System.Drawing.Printing.PrintDocument.Print method is called and before
the first page of the document prints.
Declaration
protected override void OnBeginPrint(PrintEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.Printing.PrintEventArgs | e | A System.Drawing.Printing.PrintEventArgs that contains the event data. |
OnPrintPage(PrintPageEventArgs)
Raises the System.Drawing.Printing.PrintDocument.PrintPage event. It is called
before a page prints.
Declaration
protected override void OnPrintPage(PrintPageEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.Printing.PrintPageEventArgs | e | A System.Drawing.Printing.PrintPageEventArgs that contains the event data. |
OnQueryPageSettings(QueryPageSettingsEventArgs)
Raises the System.Drawing.Printing.PrintDocument.QueryPageSettings event. It
is called immediately before each System.Drawing.Printing.PrintDocument.PrintPage
event.
Declaration
protected override void OnQueryPageSettings(QueryPageSettingsEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.Printing.QueryPageSettingsEventArgs | e | A System.Drawing.Printing.QueryPageSettingsEventArgs that contains the event data. |
Events
BeforePrintPage
Represents the method that will handle the System.Drawing.Printing.PrintDocument.PrintPage
event of a System.Drawing.Printing.PrintDocument.
Declaration
public event PrintPageEventHandler BeforePrintPage
Event Type
| Type | Description |
|---|---|
| System.Drawing.Printing.PrintPageEventHandler |
BeforeQueryPageSettings
Represents the method that handles the System.Drawing.Printing.PrintDocument.QueryPageSettings
event of a System.Drawing.Printing.PrintDocument.
Declaration
public event QueryPageSettingsEventHandler BeforeQueryPageSettings
Event Type
| Type | Description |
|---|---|
| System.Drawing.Printing.QueryPageSettingsEventHandler |