Renders the provided URL and prints it as a PDF file as it should be displayed in a Google Chrome browser.
This API has two modes.
This mode is triggered with print=true (default)parameter. When print is set to true, the PDF file will be generated by browser's print functionality and the elements in the resulting PDF will be vectors and texts will be selectable.
When in printing mode, you can also define grayscale=true in order to get images in grayscale.
The PDF will be printed on A4 pagesize by default. If you need larger pages such as A3, B4 or simply Letter or B5 just set it such as passing the pagesize=B4 parameter
Sometimes you have HTTP Realm authentications that requires username and passwords to reach the URLs. You can set them such as username=john&password=secret
A sample request with cURL is below:
curl --request GET \ --url 'https://api.promptapi.com/url_to_pdf?url=google.com&grayscale=true&pagesize=B4' \ --header 'apikey: YOUR API KEY'
Some web pages are just not optimized for printers. So the result may be flaky. You may have no choice but to take a screenshot and then convert it to PDF. You can achieve this functionality by simply setting the print parameter to false.
When print=false, the API fetches the provided URL and takes a screenshot as it is displayed on an actual Chrome browser and then serves the output as a PDF file. The browser has a screen resolution of 1400x1080 pixels, so the output is sharp and clean.
The PDF will contain full page screenshots. It will scroll automatically and take a full height screenshot of your web page. (max height: 10.000 pixels)
You can also customize the wait time (in seconds) for taking a screenshot with the timeout parameter. Just pass timeout=5 or any value you desire for your needs. (max timeout value is 15 seconds)
We use up to date Up to date Chrome browsers to make pixel perfect screenshots and ensure support for all modern web features.
A sample cURL request to trigger screensot mode is below:
curl --request GET \ --url 'https://api.promptapi.com/url_to_pdf?url=google.com&print=false' \ --header 'apikey: YOUR API KEY'