• Public
  • Public/Protected
  • All

when a page is rendered, use these settings.

Here is an example, but see individual properties for more examples, especially for parameters that are not in this example:

"url": "http://phantomjscloud.com/examples/corpus/css-media-query-print.html",
//"renderType": "png",
"renderType": "pdf",
pdfOptions:    {
//format: "A4",
headerTemplate:"<span style='font-size: 15px; height: 200px; background-color: black; color: white; margin: 20px;'>Header or Footer. <span style='font-size: 10px;'>Keep templates simple, and inline CSS.  Page:<span class='pageNumber'>XX</span>/<span class='totalPages'>YY</span></span></span>",
//old phantomjs footer format to test conversion:
repeating:"THIS IS A FOOTER PLAIN UNFORMATED.  PAGE: %pageNum%/%numPages% . yes OK",
iFrameMaxDepth: 3,
iFrameMaxCount: 10,
//emulateDevice:"googlebot"    ,


  • IRenderSettings



Optional clipRectangle

clipRectangle: IClipOptions

This property defines the rectangular area of the web page to be rasterized when using the requestType of png or jpeg. If no clipping rectangle is set, the entire web page is captured. Beware: if you capture too large an image it can cause your request to fail (out of memory). you can choose any dimensions you wish as long as you do not exceed 32M pixels new for Chrome: as an alternative to clipRect, specify IRenderSettings.selector to automatically set the viewport.

Optional emulateMedia

emulateMedia: "screen" | "print"

new for Chrome backend. (not available on WebKit). override the CSS media type of the page.



Optional extraResponseHeaders

extraResponseHeaders: {}

BEWARE: setting custom headers can corrupt your response, making it appear to fail when it did not. use with care. custom response headers you want sent along with your response. For example, to rename the file being downloaded, you can add 'Content-Disposition: attachment; filename="downloaded.pdf"'

IMPORTANT: response headers should not exceed 128Kb or your API call may fail.

Type declaration

  • [name: string]: string

Optional iFrameMaxCount

iFrameMaxCount: number

when rendering iFrames, the maximum number of iFrames in total to parse. default is 10

Optional iFrameMaxDepth

iFrameMaxDepth: number

when rendering iFrames, the maximum depth of which to parse. default is 3

Optional omitBackground

omitBackground: boolean

new for Chrome backend. (not available on WebKit). If true, and outputting a PNG, will hide the default white background (useful for capturing transparency). If true and outputting a PDF, will hide the background graphics altogether.



Optional passThroughHeaders

passThroughHeaders: boolean

If true, we will pass through all headers received from the target URL. However, we do not pass through "content-*" and "transfer-*" headers, except for "Content-Type" if you render "html". Please note: this can potentially corrupt your response, so use with caution. extraResponseHeaders override these headers.



IMPORTANT: response headers should not exceed 128Kb or your API call may fail.

Optional passThroughStatusCode

passThroughStatusCode: boolean

new for Chrome backend. (not available on WebKit).

if true, will pass the content statusCode, irrespective of if your api call was successful.

Note: you can always check the target URL's status code by inspecting the pjsc-content-status-code response header.

Optional pdfOptions

pdfOptions: IPdfOptions

settings useful for generating PDF's

Note: by default, when generating a PDF we set the IRenderSettings.emulateMedia="screen" property. Consider setting IRenderSettings.emulateMedia="print" for a more print-friendly PDF

"renderType": "pdf",
"format": "A4",
"headerTemplate":"<div style='color:blue;font-size:18px;'><span class='pageNumber'>0</span>/<span class='totalPages'>0</span></div>",

Optional pngOptions

pngOptions: IPngOptions

optional png quality options passed to PngQuant. you must set pngOptions.optimize=true to enable these, otherwise the original non-modified png is returned.

Optional quality

quality: number

jpeg quality. 0 to 100. default 70. ignored for png, use pngOptions to set png quality.

Optional renderIFrame

renderIFrame: string

for WebKit backend only. not supported in Chrome. use clipRectangle.selector instead. specify an IFrame to render instead of the full page. must be the frame's name.

Optional selector

selector: string

new for Chrome backend. (not available on WebKit).

as an alternative to clipRectangle you may pass a CSS selector. such as "h1", and the bounding rectangle of that element will be used.

CSS selectors are like JQuery. For help, please see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors

For PlainText or Html, you can pass a selector which will render only the specified element.

For image rendering (jpeg/png) You may also send the send the special "_viewport" selector

note: selector takes precidence over any clipRectangle settings.

Optional shadowDom

shadowDom: "output" | "off"

how to handle any shadowDom included in the page/iFrames. default is "output".

  • "output" - import the shadowDom into the frame data (visible in the json output when outputAsJson:true or rendering as html). this is the default.
  • "off" - do not include the shadowDom in the output.
  • "separate" - (not yet implemented) - render the shadowDom separately from the frame html. contact support if you need this.

Optional viewport

size of the browser in pixels.

for docs and examples, see IRenderSettings.viewport.

Optional zoomFactor

zoomFactor: number

This property specifies the scaling factor for the screenshot (requestType png/pdf) choices. The default is 1, i.e. 100% zoom. Use IRenderSettings.viewport.deviceScaleFactor if you need to control screen DPI