(Optional) Whether to show the header and footer. Default: false
a HTML template, use the following classes to inject print values into their respective elements:
date
, title
, url
, pageNumber
, totalPages
If the associated margin is not explicitly set, setting a template will automatically set the margin to "1in"
Note: page css is not available to this template, so include inline-css for styling.
pdf paper size to use.
You may choose a standard paper size, or an adaptive size.
standard paper sizes: Letter
, Legal
, Tabloid
, Ledger
, and A0
to A6
adaptive sizes:
viewport
: renders pages the size of the current browser viewportonepage
: renders all the browser contents in a single pdf page.
It does this by setting the pdf page width to the current viewport width, and pdf page height to the entire page contents height.
To better control page width, remember that 96px === 1in. So to have a 8.5inch wide page, set your viewport width to 816 (also consider using zoomFactor to shrink the page contents).
onepage
is slightly buggy, so to better control page length, you can set the additional onepageFudgeFactor
sibling parameter.a HTML template, use the following CSS classes to inject print values into their respective elements:
date
, title
, url
, pageNumber
, totalPages
alternatively, you could pass the special classes as variables, as shown in this example: <span>Page %pageNumber% of %totalPages%</span>
If the associated margin is not explicitly set, setting a template will automatically set the margin to "1in"
Note: page css is not available to this template, so include inline-css for styling.
optional pdf page dimensions used if you don't specify format
.
pass a number with one of the following units: px
, in
, cm
, or mm
.
optional margin
use units such as those used for width
or height
properties
(Optional) Hides default white background and allows generating pdfs with transparency. Default: false
only used when format="onepage"
.
multiplier for pdf page height, to get it to fit on a pdf page. leaves a small blank area at the bottom.
formula is: pdfPageHeight = (browserPageHeight * fudgeFactor) + margins
(Optional) Paper ranges to print, e.g. 1-5, 8, 11-13. Default: empty (all pages)
if set to true, will use the CSS @page
size if any is present.
(Optional) Scales the rendering of the web page. Amount must be between 0.1 and 2. Default: 1
(Optional) Timeout in milliseconds. Pass 0 to disable timeout. Default: 30000
optional pdf page dimensions used if you don't specify format
.
pass a number with one of the following units: px
, in
, cm
, or mm
.
the new options for rendering PDF's using our Chrome backend. If you are using the old
WebKit
backend, seeIPdfOptions_WebKit
Note: by default PDF's use the CSS
@screen
media type. to change this, set IRenderSettings.emulateMedia to a value such asprint
If you want to rename the file (used if the user saves the pdf) set the
Content-Disposition
header via IRenderSettings.extraResponseHeaders. For example:"Content-Disposition":'attachment; filename="downloaded.pdf"'
//full api request JSON example showing use of header template { url: "https://phantomjscloud.com/examples/corpus/simple.html", renderType: 'pdf', renderSettings: { emulateMedia: 'print', pdfOptions: { headerTemplate: "Header or Footer. Keep templates simple, and inline CSS. Page:XX/YY", format: 'letter', preferCSSPageSize: true, margin: {top: '2in', bottom: 0, left: 0, right: 0} }, zoomFactor: 1 } }