Creating PDFs
This guide will show you how to create PDFs using the ScreenshotBuddy API.
Options
-
Name
urlTypestringDescriptionThe URL of the page to render. It must start with
http://orhttps://, be at most2048characters long, and point at a publicly reachable host. Private, loopback and internal addresses are refused. -
Name
pdfTypebooleanDescriptionSet this to
trueto render a PDF instead of an image. It changes which other parameters are accepted, so see creating PDFs for the options that belong to that mode. Defaults tofalse. -
Name
landscapeTypebooleanDescriptionWhether to use landscape orientation. Defaults to
false(portrait). PDFs only; sending it withoutpdfis rejected. A screenshot is shaped bywidthandheightinstead. -
Name
paperFormatTypestringDescriptionThe paper format. Possible values are
letter,legal,tabloid,ledger, anda0througha6. Defaults toa4. PDFs only; sending it withoutpdfis rejected. Useformatto set the image format of a screenshot. -
Name
widthTypenumberDescriptionThe viewport width of a screenshot, or the paper width of a PDF, between
1and10000. Must be used together withheight. For a PDF it overridespaperFormatand is read in the unit set bymarginUnit. -
Name
heightTypenumberDescriptionThe viewport height of a screenshot, or the paper height of a PDF, between
1and10000. Must be used together withwidth. For a PDF it overridespaperFormatand is read in the unit set bymarginUnit. -
Name
marginTopTypenumberDescriptionTop margin, between
0and1000, in the unit set bymarginUnit. All four margins (marginTop,marginRight,marginBottom,marginLeft) have to be set together. PDFs only; sending a margin withoutpdfis rejected. -
Name
marginRightTypenumberDescriptionRight margin, between
0and1000, in the unit set bymarginUnit. Set it together with the other three margins. PDFs only; sending a margin withoutpdfis rejected. -
Name
marginBottomTypenumberDescriptionBottom margin, between
0and1000, in the unit set bymarginUnit. Set it together with the other three margins. PDFs only; sending a margin withoutpdfis rejected. -
Name
marginLeftTypenumberDescriptionLeft margin, between
0and1000, in the unit set bymarginUnit. Set it together with the other three margins. PDFs only; sending a margin withoutpdfis rejected. -
Name
marginUnitTypestringDescriptionThe unit for the margins and for a custom paper size. Possible values are
mm,cm,inandpx. Defaults tomm. PDFs only; sending it withoutpdfis rejected, because a screenshot'swidthandheightare viewport pixels. -
Name
scaleTypenumberDescriptionIn this mode, between
0.1and2. The scale of the rendering, between1and3for screenshots and between0.1and2for PDFs. Screenshots take whole numbers only, because the browser renders at whole device scale factors; PDFs take fractions. Defaults to1. A value outside the range of the mode you are in is rejected. -
Name
cacheTypebooleanDescriptionWhether an identical repeat of this request may be answered with the rendering we already made, and whether this rendering is kept for the next one. Defaults to
true. A cached answer costs no credit, says so withX-Cache: HIT, and is counted against the account's cached-answer limit rather than against its renders; sendcache=0to render the page again, which costs a credit and a render slot as any render does. Entries belong to your own account. See caching for the whole picture. -
Name
cacheTtlTypeintegerDescriptionHow long the rendering is kept, in seconds, between
60and2592000(thirty days). Defaults to86400. Sending it withcache=0is rejected, because there is no lifetime to set on a rendering that is not being kept.
The delay parameter is not accepted for PDFs. The PDF renderer has no way to wait a fixed amount of
time before it prints, so a request that combines delay with pdf is rejected rather
than rendered without the wait you asked for.
A PDF is a rendering of whatever the server served, exactly as a screenshot is. A login wall, a
404 page or a bot challenge is printed as faithfully as the page you meant, and a
4xx or 5xx target still costs a credit. What a PDF answer does not carry is
X-Target-Status: the renderer reports nothing at all about the page behind a PDF render, so the
document itself is the only thing that says what was captured. The screenshot page explains the header under
what the target
answered.
Try PDF mode in the playground
Switch the playground to PDF mode to pick a paper format, flip to landscape, and read the generated document in the browser before you write a single line of code.