Skip to content

Render PDF

Cloudflare Browser Run

Cloudflare Browser Run

Render PDF

Render a webpage to a PDF document and return it as a file.

ActionAI Tool

Inputs

Name Type Required Description
urltextRequiredThe URL to render as PDF. Provide either url or html.
htmltextOptionalRaw HTML to render instead of a URL.
pdfOptionsobjectOptionalPDF output options.
formatselectOptionalPaper format. (options: Letter, Legal, A4, A3, A5, Tabloid)
landscapeyes/noOptionalUse landscape orientation.
printBackgroundyes/noOptionalPrint background graphics.
scalenumberOptionalScale of the webpage rendering (0.1 - 2).
pageRangestextOptionalPage ranges to print, e.g. '1-5, 8'.
displayHeaderFooteryes/noOptionalDisplay header and footer.
headerTemplatetextOptionalHTML template for the print header.
footerTemplatetextOptionalHTML template for the print footer.
marginobjectOptionalPage margins.
toptextOptionalTop margin, e.g. '1cm'.
bottomtextOptionalBottom margin.
lefttextOptionalLeft margin.
righttextOptionalRight margin.
viewportobjectOptionalViewport dimensions and device settings.
widthnumberOptionalViewport width in pixels.
heightnumberOptionalViewport height in pixels.
deviceScaleFactornumberOptionalDevice scale factor (pixel density).
gotoOptionsobjectOptionalNavigation options controlling how the page is loaded.
waitUntilselectOptionalWhen to consider navigation finished. (options: Load, DOM Content Loaded, Network Idle 0, Network Idle 2)
timeoutnumberOptionalMaximum navigation time in milliseconds.
referertextOptionalReferer header value.
cookiesarray of objectOptionalCookies to set before loading the page.
nametextRequiredCookie name.
valuetextRequiredCookie value.
domaintextOptionalCookie domain.
urltextOptionalCookie URL.
pathtextOptionalCookie path.
authenticateobjectOptionalHTTP basic auth credentials.
usernametextOptionalHTTP auth username.
passwordtextOptionalHTTP auth password.
setExtraHTTPHeadersdynamic objectOptionalExtra HTTP headers to send with the request.
userAgenttextOptionalCustom user agent string.
waitForSelectortextOptionalWait for this CSS selector before rendering.
addStyleTagarray of objectOptionalInject CSS before capture.
urltextOptionalExternal stylesheet URL.
contenttextOptionalInline CSS content.
rejectResourceTypesarray of textOptionalResource types to block.

Outputs

Name Type Description
statusCodenumberHTTP status code.
bodyobjectResult containing the generated file.
fileattachmentsThe generated PDF file, uploaded to the file store.
contentTypetextMIME type of the generated file.
sizenumberFile size in bytes.