Class DocxPdfRenderOptions
Margin values which can be copied from the main document to headers and footers applied to the document
Inheritance
Namespace: IronPdf
Assembly: IronPdf.dll
Syntax
public class DocxPdfRenderOptions : Object
DocxPdfRenderOptions is what IronPDF C# code uses for PDF generation. It represents margin values which can be copied from the main document to headers and footers applied to the document.
DocxPdfRenderOptions matters when an application needs to configure or invoke PDF generation 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 DocxPdfRenderOptions, instantiate or obtain it from the relevant entry point in the IronPDF C# API. Key properties include FirstPageNumber, ForcePaperSize, GrayScale, InputEncoding. Assign options or invoke methods on the instance to configure or perform the operation. The headers and footers covers typical usage in C# end to end.
using IronPdf;
var instance = new DocxPdfRenderOptions();
var current = instance.FirstPageNumber;
// Read or assign other properties such as ForcePaperSize, GrayScale
instance.SetCustomPaperSizeinCentimeters();For the broader workflow, see the DOCX to PDF guide in the IronPDF C# documentation. For broader context, the PDF generation portion of the IronPDF C# API contains related types that work with DocxPdfRenderOptions directly. DocxPdfRenderOptions exposes additional members beyond those highlighted above; the reference tables on this page list the full set. In application code, treat DocxPdfRenderOptions 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 DocxPdfRenderOptions property after each operation to confirm the configured state. See the constructors, properties, and methods tables below for the complete API surface of DocxPdfRenderOptions.
Constructors
DocxPdfRenderOptions()
Default Constructor. Creates a new instance of DocxPdfRenderOptions with default settings.
Declaration
public DocxPdfRenderOptions()
Fields
PaperFit
Controls how HTML content is laid out on virtual PDF paper during Word document conversion. Provides advanced layout modes beyond standard print behavior.
Modes include: Default Chrome, Zoomed, Responsive CSS, Scale-to-Page, and Continuous Feed.
Example:
options.PaperFit.UseResponsiveCssRendering(1280);
Declaration
public readonly VirtualPaperLayoutManager1 PaperFit
Field Value
| Type | Description |
|---|---|
| VirtualPaperLayoutManager1 |
See Also
Properties
FirstPageNumber
The starting page number for the PDF document. Use this to continue numbering from a previous document when splitting content.
Default: 1.
Example:
// Continue numbering from page 50:
options.FirstPageNumber = 50;
Declaration
public int FirstPageNumber { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
ForcePaperSize
Force page sizes to be exactly what is specified via PaperSize by resizing the page after generating a PDF from HTML
Useful for bypassing CSS rules which specify paper size
Declaration
public bool ForcePaperSize { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Helps correct small errors in page size when rendering HTML to PDF
GrayScale
Outputs a black-and-white PDF
Default value is false.
Declaration
public bool GrayScale { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
InputEncoding
The input character encoding as a string;
Default value is Encoding.UTF8.
Declaration
public Encoding InputEncoding { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Text.Encoding |
MailMergePrintAllInOnePdfDocument
This option enables the renderer to append all merged documents into one PdfDocument. To print separate PdfDocuments corresponding to each contact, this option should be set to false.
Declaration
public bool MailMergePrintAllInOnePdfDocument { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
MarginBottom
Bottom Pdf "paper" margin in millimeters. Set to zero for border-less and commercial printing applications.
Default value is 25.
Declaration
public double MarginBottom { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
MarginLeft
Left Pdf "paper" margin in millimeters. Set to zero for border-less and commercial printing applications.
Default value is 25.
Declaration
public double MarginLeft { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
MarginRight
Right Pdf "paper" margin in millimeters. Set to zero for border-less and commercial printing applications.
Default value is 25.
Declaration
public double MarginRight { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
MarginTop
Top Pdf "paper" margin in millimeters. Set to zero for border-less and commercial printing applications.
Default value is 25.
Declaration
public double MarginTop { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
PaperOrientation
The PDF paper orientation. E.g. Portrait or Landscape.
Default value is Portrait.
Declaration
public PdfPaperOrientation PaperOrientation { get; set; }
Property Value
| Type | Description |
|---|---|
| PdfPaperOrientation |
PaperSize
Set an output paper size for PDF pages. System.Drawing.Printing.PaperKind.
Use SetCustomPaperSize(int width, int height) for custom sizes.
Default value is A4.
Declaration
public PdfPaperSize PaperSize { get; set; }
Property Value
| Type | Description |
|---|---|
| PdfPaperSize |
PrintHtmlBackgrounds
Prints background-colors and images from Html.
Default value is true.
Declaration
public bool PrintHtmlBackgrounds { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Timeout
Maximum time in seconds to wait for Word document conversion to complete. Increase for complex documents with many images or extensive formatting.
Default: 60 seconds.
Example:
// Allow 5 minutes for large documents:
options.Timeout = 300;
Declaration
public int Timeout { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
WaitFor
A wrapper object that holds configuration for wait-for mechanism for user to wait for certain events before rendering.
Declaration
public WaitFor WaitFor { get; set; }
Property Value
| Type | Description |
|---|---|
| WaitFor |
Remarks
By default, it will wait for nothing.
Methods
SetCustomPaperSizeinCentimeters(Double, Double)
Set an output paper size for PDF pages. Dimensions are in Centimeters.
Declaration
public void SetCustomPaperSizeinCentimeters(double width, double height)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | width | Custom paper width in cm. |
| System.Double | height |
|
SetCustomPaperSizeInInches(Double, Double)
Set an output paper size for PDF pages. Dimensions are in Inches.
Declaration
public void SetCustomPaperSizeInInches(double width, double height)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | width | Custom paper width in Inches. |
| System.Double | height |
|
SetCustomPaperSizeinMilimeters(Double, Double)
Set an output paper size for PDF pages. Dimensions are in millimeters.
Declaration
public void SetCustomPaperSizeinMilimeters(double width, double height)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | width | Custom paper width in millimeters. |
| System.Double | height |
|
SetCustomPaperSizeinPixelsOrPoints(Double, Double, Int32)
Set an output paper size for PDF pages. Dimensions are in screen Pixels or printer Points.
Declaration
public void SetCustomPaperSizeinPixelsOrPoints(double width, double height, int DPI = 96)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | width | Custom paper width in pixels/points. |
| System.Double | height |
|
| System.Int32 | DPI |
|