renders the content of the page (html or plainText). default will render html of the entire page.
options
selector
: html selector of the element you want to render. defaults to "html" (full page)type
: default "html". choose "plainText" to only render text.NOTE You may also supply [[types.FrameExecOptions]] options which will allow you to query a specific frame (either main Page Frame or child IFrames).
render a pdf of the current page contents.
options
Pass null/nothing to use the phantomJsCloud standard JSON api [[IRenderSettings.IPdfOptions]] (including 'onepage
' support)
<Object> Options object which might have the following properties:
path
<string> The name of the PDF.scale
<number> Scale of the webpage rendering. Defaults to 1. Scale amount must be between 0.1 and 2.displayHeaderFooter
<boolean> Display header and footer. Defaults to false.headerTemplate
<string> HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them:date
formatted print datetitle
document titleurl
document locationpageNumber
current page numbertotalPages
total pages in the documentfooterTemplate
<string> HTML template for the print footer. Should use the same format as the headerTemplate.printBackground
<boolean> Print background graphics. Defaults to false.landscape
<boolean> Paper orientation. Defaults to false.pageRanges
<string> Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.format
<string> Paper format. If set, takes priority over width or height options. Defaults to 'Letter'.width
<string|number< Paper width, accepts values labeled with units.height
<string|number< Paper height, accepts values labeled with units.margin
<Object> Paper margins, defaults to none.top
<string|number< Top margin, accepts values labeled with units.right
<string|number< Right margin, accepts values labeled with units.bottom
<string|number< Bottom margin, accepts values labeled with units.left
<string|number< Left margin, accepts values labeled with units.preferCSSPageSize
<boolean> 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.page.pdf()
generates a pdf of the page with print css media. To generate a pdf with screen
media, call page.emulateMedia('screen')
before calling page.pdf()
:
NOTE By default, page.pdf()
generates a pdf with modified colors for printing. Use the -webkit-print-color-adjust property to force rendering of exact colors.
// Generates a PDF with 'screen' media type.
await page.emulateMedia('screen');
await page.pdf({path: 'page.pdf'});
The width
, height
, and margin
options accept values labeled with units. Unlabeled values are treated as pixels.
A few examples:
page.pdf({width: 100}) - prints with width set to 100 pixels
page.pdf({width: '100px'}) - prints with width set to 100 pixels
page.pdf({width: '10cm'}) - prints with width set to 10 centimeters.
All possible units are:
px
- pixelin
- inchcm
- centimetermm
- millimeterThe format
options are:
Letter
: 8.5in x 11inLegal
: 8.5in x 14inTabloid
: 11in x 17inLedger
: 17in x 11inA0
: 33.1in x 46.8inA1
: 23.4in x 33.1inA2
: 16.54in x 23.4inA3
: 11.7in x 16.54inA4
: 8.27in x 11.7inA5
: 5.83in x 8.27inA6
: 4.13in x 5.83inNOTE headerTemplate and footerTemplate markup have the following limitations:
render a screenshot of the current page contents
options
<Object> Options object which might have the following properties:path
<string> The file path to save the image to. The screenshot type will be inferred from file extension. If path is a relative path, then it is resolved relative to current working directory. If no path is provided, the image won't be saved to the disk.type
<string> Specify screenshot type, can be either jpeg or png. Defaults to 'png'.quality
<number> The quality of the image, between 0-100. Not applicable to png images.fullPage
<boolean> When true, takes a screenshot of the full scrollable page. Defaults to false.clip
<Object> An object which specifies clipping region of the page. Should have the following fields:x
<number> x-coordinate of top-left corner of clip areay
<number> y-coordinate of top-left corner of clip areawidth
<number> width of clipping areaheight
<number> height of clipping areaomitBackground
<boolean> Hides default white background and allows capturing screenshots with transparency. Defaults to false.encoding
<string> The encoding of the image, can be either base64 or binary. Defaults to binary.
Render the page and store it in
userResponse.content.automation.renders
ifoutputAsJson:true
is setNOTE: While the Automation feature is in preview, you may make up to 3 renders per request.