Class Page.PdfOptions

java.lang.Object
com.microsoft.playwright.Page.PdfOptions
Enclosing interface:
Page

public static class Page.PdfOptions extends Object
  • Field Details

    • displayHeaderFooter

      public Boolean displayHeaderFooter
      Display header and footer. Defaults to false.
    • footerTemplate

      public String footerTemplate
      HTML template for the print footer. Should use the same format as the headerTemplate.
    • format

      public String format
      Paper format. If set, takes priority over width or height options. 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 to false.
    • margin

      public Margin margin
      Paper margins, defaults to none.
    • 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. If path is 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 @page size declared in the page priority over what is declared in width and height or format options. Defaults to false, which will scale the content to fit the paper size.
    • printBackground

      public Boolean printBackground
      Print background graphics. Defaults to false.
    • scale

      public Double scale
      Scale of the webpage rendering. Defaults to 1. Scale amount must be between 0.1 and 2.
    • width

      public String width
      Paper width, accepts values labeled with units.
  • Constructor Details

    • PdfOptions

      public PdfOptions()
  • Method Details

    • setDisplayHeaderFooter

      public Page.PdfOptions setDisplayHeaderFooter(boolean displayHeaderFooter)
      Display header and footer. Defaults to false.
    • setFooterTemplate

      public Page.PdfOptions setFooterTemplate(String footerTemplate)
      HTML template for the print footer. Should use the same format as the headerTemplate.
    • setFormat

      public Page.PdfOptions setFormat(String format)
      Paper format. If set, takes priority over width or height options. 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 to false.
    • setMargin

      public Page.PdfOptions setMargin(Margin margin)
      Paper margins, defaults to none.
    • 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. If path is 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 @page size declared in the page priority over what is declared in width and height or format options. Defaults to false, which will scale the content to fit the paper size.
    • setPrintBackground

      public Page.PdfOptions setPrintBackground(boolean printBackground)
      Print background graphics. Defaults to false.
    • setScale

      public Page.PdfOptions setScale(double scale)
      Scale of the webpage rendering. Defaults to 1. Scale amount must be between 0.1 and 2.
    • setWidth

      public Page.PdfOptions setWidth(String width)
      Paper width, accepts values labeled with units.