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
| Name | Description |
|---|---|
| PrintOptions() |
PrintOptions()
PrintOptions.cspublic PrintOptions()No documentation is available.
Properties
| Name | Description |
|---|---|
| Default | Gets the default options: US Letter pages (8.5in x 11in) with margins of 0.5in. |
| DisplayHeaderFooter | 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. |
| FooterTemplate | 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. |
| HeaderTemplate | 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. |
| Landscape | 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. |
| MarginBottom | Gets or sets the bottom margin of the pages when no @page rule sets it, in CSS pixels. The default is 48 (0.5in). |
| MarginLeft | Gets or sets the left margin of the pages when no @page rule sets it, in CSS pixels. The default is 48 (0.5in). |
| MarginRight | Gets or sets the right margin of the pages when no @page rule sets it, in CSS pixels. The default is 48 (0.5in). |
| MarginTop | Gets or sets the top margin of the pages when no @page rule sets it, in CSS pixels. The default is 48 (0.5in). |
| PageHeight | Gets or sets the height of the pages (the page box of size: auto), in CSS pixels. The default is 1056 (11in). |
| PageRanges | 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. |
| PageWidth | Gets or sets the width of the pages (the page box of size: auto), in CSS pixels. The default is 816 (8.5in). |
| PreferCssPageSize | 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. |
| PrintBackground | 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). |
| SafePrintableInset | 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). |
| Scale | 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. |
Default
PrintOptions.csGets the default options: US Letter pages (8.5in x 11in) with margins of 0.5in.
public static PrintOptions Default { get; }Property value
HeaderTemplate
PrintOptions.csGets 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
Landscape
PrintOptions.csMarginBottom
PrintOptions.csMarginLeft
PrintOptions.csMarginRight
PrintOptions.csMarginTop
PrintOptions.csPageHeight
PrintOptions.csPageRanges
PrintOptions.csGets 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
PageWidth
PrintOptions.csPreferCssPageSize
PrintOptions.csGets 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
PrintBackground
PrintOptions.csGets 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
SafePrintableInset
PrintOptions.csGets 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
Scale
PrintOptions.csGets 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
Methods
| Name | Description |
|---|---|
| Equals(PrintOptions?) | |
| Equals(object?) | |
| GetHashCode() | |
| ToString() |
Equals overloads
Equals(PrintOptions?)
public bool Equals(PrintOptions? other)No documentation is available.
Equals(object?)
GetHashCode()
ToString()
Operators
| Name | Description |
|---|---|
| operator ==(PrintOptions?, PrintOptions?) | |
| operator !=(PrintOptions?, PrintOptions?) |
operator ==(PrintOptions?, PrintOptions?)
public static bool operator ==(PrintOptions? left, PrintOptions? right)No documentation is available.
operator !=(PrintOptions?, PrintOptions?)
public static bool operator !=(PrintOptions? left, PrintOptions? right)No documentation is available.