---
title: Take a PDF from any page
description: Generate a live PDF from any page, without writing any code.
source_url:
  html: https://testingbot.com/support/functions/pdf
  md: https://testingbot.com/support/functions/pdf/index.md
---
# PDF Function

This function will generate a PDF from any webpage. TestingBot will launch a remote browser, visit the URL you specified and take a PDF from it.

Use the URLs below to take an instant PDF from a page, without having to write any code.

Instead of relying on tools such as wkhtmltopdf, PDFShift, Athena, PDFBlade or others, you can rely on the power of Chrome's rendering engine to take a high quality PDF through a Function (which uses Puppeteer behind the scenes).

## Example

    curl -X POST https://cloud.testingbot.com/pdf?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN11 \
    -H 'Content-Type: application/json' \
    -d '{"url":"https://testingbot.com"}' > test.pdf

This simple example will run a Puppeteer script on our service and do the following:

- Start a Headless Browser (latest version) on our cloud
- Connect with Puppeteer to the Browser and navigate to the URL you specified
- Generate a PDF from the page
- Return the `PDF file` back to you, in a file called `test.pdf`

## Specifying browser and version

See the example below to specify on which platform configuration you'd like to generate the PDF on. You can specify a `browserName`, `version` and `platform`.

  ![OS selected](https://testingbot.com/assets/environments/svg/windows11-0e1b28bc0fdd5034d3e4d3dc8d346c500a8c6522facf4b45d0da56537c1f1c6d.svg) Windows 11 › ![Browser selected](https://testingbot.com/assets/environments/svg/chrome-c4081ff447d2d898d4afcb8f074a907c960e6f007716c1a1d119eee6803c4042.svg) Chrome 139 

Loading environments...

Please wait while we load the available browsers and platforms.

    

## PDF Options

You can specify additional options with this function call to customize the PDF taking.

This function call can use any of the Puppeteer [puppeteer.pdfoptions](https://pptr.dev/api/puppeteer.pdfoptions) options.

    curl -X POST https://cloud.testingbot.com/pdf?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN11 \
    -H 'Content-Type: application/json' \
    -d '{"url":"https://testingbot.com", "options":{"fullPage":true}}' > test.pdf

### Authenticate options

You can specify the [page.authenticate](https://pptr.dev/api/puppeteer.page.authenticate/) credentials.

    curl -X POST https://cloud.testingbot.com/pdf?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN11 \
    -H 'Content-Type: application/json' \
    -d '{"url":"https://testingbot.com", "authenticate":{ "username": "user", "password": "passwd" }}' > test.pdf

### Goto options

You can specify the [page.goto](https://pptr.dev/api/puppeteer.page.goto) options and add `timeout` and `waitUntil` settings.

    curl -X POST https://cloud.testingbot.com/pdf?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN11 \
    -H 'Content-Type: application/json' \
    -d '{"url":"https://testingbot.com", "gotoOptions":{ "waitUntil": "networkidle2" }}' > test.pdf

### Extra Headers

You can specify the [page.setExtraHTTPHeaders](https://pptr.dev/api/puppeteer.page.setextrahttpheaders) options to add extra HTTP headers to the request that the TestingBot browser makes.

    curl -X POST https://cloud.testingbot.com/pdf?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN11 \
    -H 'Content-Type: application/json' \
    -d '{"url":"https://testingbot.com", "extraHeaders":{ "foo": "bar" }}' > test.pdf

### Disable Javascript

You can disable Javascript with the [page.setJavaScriptEnabled](https://pptr.dev/api/puppeteer.page.setjavascriptenabled) option.

    curl -X POST https://cloud.testingbot.com/pdf?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN11 \
    -H 'Content-Type: application/json' \
    -d '{"url":"https://testingbot.com", "javascriptEnabled":false}' > test.pdf

### Emulate Media

Change the CSS media type of the page with [page.emulateMediaType](https://pptr.dev/api/puppeteer.page.emulatemediatype).

    curl -X POST https://cloud.testingbot.com/pdf?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN11 \
    -H 'Content-Type: application/json' \
    -d '{"url":"https://testingbot.com", "emulateMedia":"print"}' > test.pdf

### Looking for more help?

Have questions or need more information? Reach out via email or Slack.

[Email us](https://testingbot.com/contact/new)[Slack Join our Slack](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
