Package com.microsoft.playwright
Class Page.PdfOptions
- java.lang.Object
-
- com.microsoft.playwright.Page.PdfOptions
-
-
Field Summary
Fields Modifier and Type Field Description BooleandisplayHeaderFooterDisplay header and footer.StringfooterTemplateHTML template for the print footer.StringformatPaper format.StringheaderTemplateHTML template for the print header.StringheightPaper height, accepts values labeled with units.BooleanlandscapePaper orientation.MarginmarginPaper margins, defaults to none.BooleanoutlineWhether or not to embed the document outline into the PDF.StringpageRangesPaper ranges to print, e.g., '1-5, 8, 11-13'.PathpathThe file path to save the PDF to.BooleanpreferCSSPageSizeGive any CSS@pagesize declared in the page priority over what is declared inwidthandheightorformatoptions.BooleanprintBackgroundPrint background graphics.DoublescaleScale of the webpage rendering.BooleantaggedWhether or not to generate tagged (accessible) PDF.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(String footerTemplate)HTML template for the print footer.Page.PdfOptionssetFormat(String format)Paper format.Page.PdfOptionssetHeaderTemplate(String headerTemplate)HTML template for the print header.Page.PdfOptionssetHeight(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.PdfOptionssetOutline(boolean outline)Whether or not to embed the document outline into the PDF.Page.PdfOptionssetPageRanges(String pageRanges)Paper ranges to print, e.g., '1-5, 8, 11-13'.Page.PdfOptionssetPath(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.PdfOptionssetTagged(boolean tagged)Whether or not to generate tagged (accessible) PDF.Page.PdfOptionssetWidth(String width)Paper width, accepts values labeled with units.
-
-
-
Field Detail
-
displayHeaderFooter
public Boolean displayHeaderFooter
Display header and footer. Defaults tofalse.
-
footerTemplate
public String footerTemplate
HTML template for the print footer. Should use the same format as theheaderTemplate.
-
format
public String format
Paper format. If set, takes priority overwidthorheightoptions. Defaults to 'Letter'.
-
headerTemplate
public 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 String height
Paper height, accepts values labeled with units.
-
landscape
public Boolean landscape
Paper orientation. Defaults tofalse.
-
margin
public Margin margin
Paper margins, defaults to none.
-
outline
public Boolean outline
Whether or not to embed the document outline into the PDF. Defaults tofalse.
-
pageRanges
public 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 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 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 Boolean printBackground
Print background graphics. Defaults tofalse.
-
scale
public Double scale
Scale of the webpage rendering. Defaults to1. Scale amount must be between 0.1 and 2.
-
tagged
public Boolean tagged
Whether or not to generate tagged (accessible) PDF. Defaults tofalse.
-
width
public 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(String footerTemplate)
HTML template for the print footer. Should use the same format as theheaderTemplate.
-
setFormat
public Page.PdfOptions setFormat(String format)
Paper format. If set, takes priority overwidthorheightoptions. Defaults to 'Letter'.
-
setHeaderTemplate
public Page.PdfOptions setHeaderTemplate(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(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.
-
setOutline
public Page.PdfOptions setOutline(boolean outline)
Whether or not to embed the document outline into the PDF. Defaults tofalse.
-
setPageRanges
public Page.PdfOptions setPageRanges(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(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.
-
setTagged
public Page.PdfOptions setTagged(boolean tagged)
Whether or not to generate tagged (accessible) PDF. Defaults tofalse.
-
setWidth
public Page.PdfOptions setWidth(String width)
Paper width, accepts values labeled with units.
-
-