Package com.microsoft.playwright
Class Page.PdfOptions
- java.lang.Object
-
- com.microsoft.playwright.Page.PdfOptions
-
- Enclosing interface:
- Page
public static class Page.PdfOptions extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.BooleandisplayHeaderFooterDisplay header and footer.java.lang.StringfooterTemplateHTML template for the print footer.java.lang.StringformatPaper format.java.lang.StringheaderTemplateHTML template for the print header.java.lang.StringheightPaper height, accepts values labeled with units.java.lang.BooleanlandscapePaper orientation.MarginmarginPaper margins, defaults to none.java.lang.StringpageRangesPaper ranges to print, e.g., '1-5, 8, 11-13'.java.nio.file.PathpathThe file path to save the PDF to.java.lang.BooleanpreferCSSPageSizeGive any CSS@pagesize declared in the page priority over what is declared inwidthandheightorformatoptions.java.lang.BooleanprintBackgroundPrint background graphics.java.lang.DoublescaleScale of the webpage rendering.java.lang.StringwidthPaper width, accepts values labeled with units.
-
Constructor Summary
Constructors Constructor Description PdfOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Page.PdfOptionssetDisplayHeaderFooter(boolean displayHeaderFooter)Display header and footer.Page.PdfOptionssetFooterTemplate(java.lang.String footerTemplate)HTML template for the print footer.Page.PdfOptionssetFormat(java.lang.String format)Paper format.Page.PdfOptionssetHeaderTemplate(java.lang.String headerTemplate)HTML template for the print header.Page.PdfOptionssetHeight(java.lang.String height)Paper height, accepts values labeled with units.Page.PdfOptionssetLandscape(boolean landscape)Paper orientation.Page.PdfOptionssetMargin(Margin margin)Paper margins, defaults to none.Page.PdfOptionssetPageRanges(java.lang.String pageRanges)Paper ranges to print, e.g., '1-5, 8, 11-13'.Page.PdfOptionssetPath(java.nio.file.Path path)The file path to save the PDF to.Page.PdfOptionssetPreferCSSPageSize(boolean preferCSSPageSize)Give any CSS@pagesize declared in the page priority over what is declared inwidthandheightorformatoptions.Page.PdfOptionssetPrintBackground(boolean printBackground)Print background graphics.Page.PdfOptionssetScale(double scale)Scale of the webpage rendering.Page.PdfOptionssetWidth(java.lang.String width)Paper width, accepts values labeled with units.
-
-
-
Field Detail
-
displayHeaderFooter
public java.lang.Boolean displayHeaderFooter
Display header and footer. Defaults tofalse.
-
footerTemplate
public java.lang.String footerTemplate
HTML template for the print footer. Should use the same format as theheaderTemplate.
-
format
public java.lang.String format
Paper format. If set, takes priority overwidthorheightoptions. Defaults to 'Letter'.
-
headerTemplate
public java.lang.String headerTemplate
HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them:-
"date"formatted print date -
"title"document title -
"url"document location -
"pageNumber"current page number -
"totalPages"total pages in the document
-
-
height
public java.lang.String height
Paper height, accepts values labeled with units.
-
landscape
public java.lang.Boolean landscape
Paper orientation. Defaults tofalse.
-
margin
public Margin margin
Paper margins, defaults to none.
-
pageRanges
public java.lang.String pageRanges
Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
-
path
public java.nio.file.Path path
The file path to save the PDF to. Ifpathis a relative path, then it is resolved relative to the current working directory. If no path is provided, the PDF won't be saved to the disk.
-
preferCSSPageSize
public java.lang.Boolean preferCSSPageSize
Give any CSS@pagesize declared in the page priority over what is declared inwidthandheightorformatoptions. Defaults tofalse, which will scale the content to fit the paper size.
-
printBackground
public java.lang.Boolean printBackground
Print background graphics. Defaults tofalse.
-
scale
public java.lang.Double scale
Scale of the webpage rendering. Defaults to1. Scale amount must be between 0.1 and 2.
-
width
public java.lang.String width
Paper width, accepts values labeled with units.
-
-
Method Detail
-
setDisplayHeaderFooter
public Page.PdfOptions setDisplayHeaderFooter(boolean displayHeaderFooter)
Display header and footer. Defaults tofalse.
-
setFooterTemplate
public Page.PdfOptions setFooterTemplate(java.lang.String footerTemplate)
HTML template for the print footer. Should use the same format as theheaderTemplate.
-
setFormat
public Page.PdfOptions setFormat(java.lang.String format)
Paper format. If set, takes priority overwidthorheightoptions. Defaults to 'Letter'.
-
setHeaderTemplate
public Page.PdfOptions setHeaderTemplate(java.lang.String headerTemplate)
HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them:-
"date"formatted print date -
"title"document title -
"url"document location -
"pageNumber"current page number -
"totalPages"total pages in the document
-
-
setHeight
public Page.PdfOptions setHeight(java.lang.String height)
Paper height, accepts values labeled with units.
-
setLandscape
public Page.PdfOptions setLandscape(boolean landscape)
Paper orientation. Defaults tofalse.
-
setMargin
public Page.PdfOptions setMargin(Margin margin)
Paper margins, defaults to none.
-
setPageRanges
public Page.PdfOptions setPageRanges(java.lang.String pageRanges)
Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
-
setPath
public Page.PdfOptions setPath(java.nio.file.Path path)
The file path to save the PDF to. Ifpathis a relative path, then it is resolved relative to the current working directory. If no path is provided, the PDF won't be saved to the disk.
-
setPreferCSSPageSize
public Page.PdfOptions setPreferCSSPageSize(boolean preferCSSPageSize)
Give any CSS@pagesize declared in the page priority over what is declared inwidthandheightorformatoptions. Defaults tofalse, which will scale the content to fit the paper size.
-
setPrintBackground
public Page.PdfOptions setPrintBackground(boolean printBackground)
Print background graphics. Defaults tofalse.
-
setScale
public Page.PdfOptions setScale(double scale)
Scale of the webpage rendering. Defaults to1. Scale amount must be between 0.1 and 2.
-
setWidth
public Page.PdfOptions setWidth(java.lang.String width)
Paper width, accepts values labeled with units.
-
-