Rendering PDFs
How to render PDFs with Urlbox from URL or HTML
To render PDF's with Urlbox, set the format to pdf
and pass in a URL or HTML and any relevant options.
Request
When rendering PDF's the default is to render the entire website into multiple pages of a PDF document.
You can specify a specific page, or page range to render by passing in the pdf_page_range
option.
This option works similar to a typical print dialog in a web browser, for example to print the first page, and then the third to the fifth page, you would pass in 1,3-5
.
Request
To render the full website into a single page in the PDF document, set full_page
to true.
Request
Render PDF from HTML
To render a PDF from some HTML, pass in the html
option with the HTML you want to render. If the HTML has relative links to images, stylesheets or other resources, you can pass in the base_url
option to specify the base URL to use for relative links.
Request
Change the PDF page size
To change the PDF page size to a predetermined page size, set the pdf_page_size
option.
To set the PDF page size to a custom size, set the pdf_page_width
and pdf_page_height
options.
Change the default stylesheet
By default when capturing PDF documents, Urlbox will use the print stylesheet to render the page.
Some sites that make use of a print specific stylesheet may appear different on the PDF to how they appear in a web browser.
To change the stylesheet to the regular stylesheet, set the media
option to screen
.