PrintOptions Class

The settings of the printing of a document into pages (https://drafts.csswg.org/css-page-3/): the size of the pages and their margins when the style sheets do not set them (@page { size; margin }). The document is laid out with the print media type.

public sealed class PrintOptions : IEquatable<PrintOptions>
Implements

Constructors

NameDescription
PrintOptions()

PrintOptions()

PrintOptions.cs
public PrintOptions()

No documentation is available.

Properties

NameDescription
DefaultGets the default options: US Letter pages (8.5in x 11in) with margins of 0.5in.
DisplayHeaderFooterGets or sets whether the header and the footer templates (PrintOptions.HeaderTemplate, PrintOptions.FooterTemplate) are printed in the top and bottom margins of the pages (as the displayHeaderFooter option of the PDF of Playwright). The default is false.
FooterTemplateGets or sets the HTML of the footer of the pages, rendered in their bottom margin (see PrintOptions.HeaderTemplate). The default is null: no footer.
HeaderTemplateGets or sets the HTML of the header of the pages (with PrintOptions.DisplayHeaderFooter), as the headerTemplate option of the PDF of Playwright: it is rendered in the top margin of each page, as wide as the page; the content of its elements of class date, title, url, pageNumber and totalPages is the date of the printing, the title of the document, its URL, the number of the page and the number of pages. Its scripts do not run and only its inline resources (data: URLs) are loaded. The default is null: no header.
LandscapeGets or sets whether the pages are in landscape orientation: the width and the height of the pages of size: auto are swapped (as the landscape option of the PDF of Playwright). The default is false.
MarginBottomGets or sets the bottom margin of the pages when no @page rule sets it, in CSS pixels. The default is 48 (0.5in).
MarginLeftGets or sets the left margin of the pages when no @page rule sets it, in CSS pixels. The default is 48 (0.5in).
MarginRightGets or sets the right margin of the pages when no @page rule sets it, in CSS pixels. The default is 48 (0.5in).
MarginTopGets or sets the top margin of the pages when no @page rule sets it, in CSS pixels. The default is 48 (0.5in).
PageHeightGets or sets the height of the pages (the page box of size: auto), in CSS pixels. The default is 1056 (11in).
PageRangesGets or sets the pages to print, as the pageRanges option of the PDF of Playwright: the 1-based numbers of the pages and the ranges of pages separated by commas (e.g. 1-5, 8, 11-13; -3 is the first three pages and 11- the pages from the eleventh one). The pages are printed once, in order; the numbers beyond the last page are ignored, and the pages keep their numbers (counter(page)). The default is null: all the pages.
PageWidthGets or sets the width of the pages (the page box of size: auto), in CSS pixels. The default is 816 (8.5in).
PreferCssPageSizeGets or sets whether the size of the pages set by the size descriptor of the @page rules is the size of the printed pages (as the preferCSSPageSize option of the PDF of Playwright). The default is true. When it is false, the pages are printed on the paper of the options (PrintOptions.PageWidth x PrintOptions.PageHeight, in the orientation of the page box): a page box of another size is centered on it, scaled down when it does not fit.
PrintBackgroundGets or sets whether the backgrounds are printed. The default is true. When it is false (as the default printBackground: false of Playwright), as in the browsers, the boxes whose print-color-adjust is economy (the initial value) paint a white background instead of their background color and images, and their text, when it is almost white, is darkened (https://drafts.csswg.org/css-color-adjust-1/#print-color-adjust).
SafePrintableInsetGets or sets the safe printable inset of the pages, in CSS pixels: the width of the region along each edge of the page sheet that the printer cannot print, used by the page-margin-safety descriptor of @page and of the margin rules (https://drafts.csswg.org/css-page-3/#page-margin-safety). The default is 0 (the whole sheet is printable).
ScaleGets or sets the scale of the content of the pages, from 0.1 to 2 (as the scale option of the PDF of Playwright): the content is laid out in the page area divided by the scale, then painted scaled (the page margins and the page-margin boxes are not scaled). The default is 1.

Gets the default options: US Letter pages (8.5in x 11in) with margins of 0.5in.

public static PrintOptions Default { get; }

Property value

PrintOptions

DisplayHeaderFooter

PrintOptions.cs

Gets or sets whether the header and the footer templates (PrintOptions.HeaderTemplate, PrintOptions.FooterTemplate) are printed in the top and bottom margins of the pages (as the displayHeaderFooter option of the PDF of Playwright). The default is false.

public bool DisplayHeaderFooter { get; init; }

Property value

bool

FooterTemplate

PrintOptions.cs

Gets or sets the HTML of the footer of the pages, rendered in their bottom margin (see PrintOptions.HeaderTemplate). The default is null: no footer.

public string? FooterTemplate { get; init; }

Property value

string?

HeaderTemplate

PrintOptions.cs

Gets or sets the HTML of the header of the pages (with PrintOptions.DisplayHeaderFooter), as the headerTemplate option of the PDF of Playwright: it is rendered in the top margin of each page, as wide as the page; the content of its elements of class date, title, url, pageNumber and totalPages is the date of the printing, the title of the document, its URL, the number of the page and the number of pages. Its scripts do not run and only its inline resources (data: URLs) are loaded. The default is null: no header.

public string? HeaderTemplate { get; init; }

Property value

string?

Gets or sets whether the pages are in landscape orientation: the width and the height of the pages of size: auto are swapped (as the landscape option of the PDF of Playwright). The default is false.

public bool Landscape { get; init; }

Property value

bool

MarginBottom

PrintOptions.cs

Gets or sets the bottom margin of the pages when no @page rule sets it, in CSS pixels. The default is 48 (0.5in).

public double MarginBottom { get; init; }

Property value

double

MarginLeft

PrintOptions.cs

Gets or sets the left margin of the pages when no @page rule sets it, in CSS pixels. The default is 48 (0.5in).

public double MarginLeft { get; init; }

Property value

double

MarginRight

PrintOptions.cs

Gets or sets the right margin of the pages when no @page rule sets it, in CSS pixels. The default is 48 (0.5in).

public double MarginRight { get; init; }

Property value

double

Gets or sets the top margin of the pages when no @page rule sets it, in CSS pixels. The default is 48 (0.5in).

public double MarginTop { get; init; }

Property value

double

PageHeight

PrintOptions.cs

Gets or sets the height of the pages (the page box of size: auto), in CSS pixels. The default is 1056 (11in).

public double PageHeight { get; init; }

Property value

double

PageRanges

PrintOptions.cs

Gets or sets the pages to print, as the pageRanges option of the PDF of Playwright: the 1-based numbers of the pages and the ranges of pages separated by commas (e.g. 1-5, 8, 11-13; -3 is the first three pages and 11- the pages from the eleventh one). The pages are printed once, in order; the numbers beyond the last page are ignored, and the pages keep their numbers (counter(page)). The default is null: all the pages.

public string? PageRanges { get; init; }

Property value

string?

Gets or sets the width of the pages (the page box of size: auto), in CSS pixels. The default is 816 (8.5in).

public double PageWidth { get; init; }

Property value

double

PreferCssPageSize

PrintOptions.cs

Gets or sets whether the size of the pages set by the size descriptor of the @page rules is the size of the printed pages (as the preferCSSPageSize option of the PDF of Playwright). The default is true. When it is false, the pages are printed on the paper of the options (PrintOptions.PageWidth x PrintOptions.PageHeight, in the orientation of the page box): a page box of another size is centered on it, scaled down when it does not fit.

public bool PreferCssPageSize { get; init; }

Property value

bool

PrintBackground

PrintOptions.cs

Gets or sets whether the backgrounds are printed. The default is true. When it is false (as the default printBackground: false of Playwright), as in the browsers, the boxes whose print-color-adjust is economy (the initial value) paint a white background instead of their background color and images, and their text, when it is almost white, is darkened (https://drafts.csswg.org/css-color-adjust-1/#print-color-adjust).

public bool PrintBackground { get; init; }

Property value

bool

SafePrintableInset

PrintOptions.cs

Gets or sets the safe printable inset of the pages, in CSS pixels: the width of the region along each edge of the page sheet that the printer cannot print, used by the page-margin-safety descriptor of @page and of the margin rules (https://drafts.csswg.org/css-page-3/#page-margin-safety). The default is 0 (the whole sheet is printable).

public double SafePrintableInset { get; init; }

Property value

double

Gets or sets the scale of the content of the pages, from 0.1 to 2 (as the scale option of the PDF of Playwright): the content is laid out in the page area divided by the scale, then painted scaled (the page margins and the page-margin boxes are not scaled). The default is 1.

public double Scale { get; init; }

Property value

double

Methods

NameDescription
Equals(PrintOptions?)
Equals(object?)
GetHashCode()
ToString()

Equals overloads

Equals(PrintOptions?)

public bool Equals(PrintOptions? other)
Parameters
other PrintOptions?
Returns

bool

No documentation is available.

Equals(object?)

public override bool Equals(object? obj)
Parameters
obj object?
Returns

bool

No documentation is available.

GetHashCode()

public override int GetHashCode()

Returns

int

No documentation is available.

ToString()

public override string ToString()

Returns

string

No documentation is available.

Operators

NameDescription
operator ==(PrintOptions?, PrintOptions?)
operator !=(PrintOptions?, PrintOptions?)

operator ==(PrintOptions?, PrintOptions?)

public static bool operator ==(PrintOptions? left, PrintOptions? right)

Parameters

left PrintOptions?
right PrintOptions?

Returns

bool

No documentation is available.

operator !=(PrintOptions?, PrintOptions?)

public static bool operator !=(PrintOptions? left, PrintOptions? right)

Parameters

left PrintOptions?
right PrintOptions?

Returns

bool

No documentation is available.