Converting HTML & CSS into a PDF is simple with Urlbox.
It's a little more involved than converting a URL to a PDF. You need to send Urlbox your HTML and CSS.
First you need to prepare your HTML and CSS. We've added width, height and retina options here so it renders nicely.
All that needs to be URI encoded for Urlbox to process it as a GET request:
Linking to a dynamic PDF
Yes you can literally create a link to that and your users will be able to view the PDF:
Which would result in this:
PDF download link
Maybe you want users to download the PDF with a particular filename? Easy, just add one parameter:
Which would result in this:
All the PDF options you need
There are over a dozen PDF-specific options in the Urlbox API.
Set the page size to A4, Letter or one of 9 other alternatives. Change the print margins, scale, background and more.
Full documentation here.
You're not limited to generating PDFs with Urlbox
Urlbox has many output formats beyond PDF. You can also render:
- PNG
- JPEG
- WebP
- SVG
- AVIF
- HTML (after JS has executed)
- JSON (Coming soon).
More Urlbox Features
Urlbox is powerful with dozens of features for taking screenshots at scale.
If you found this useful you might also want to checkout some of our other popular Urlbox features: