> For the complete documentation index, see [llms.txt](https://docs.htmlcsstoimg.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.htmlcsstoimg.com/html-to-image-api/generate-pdf-api.md).

# Generate PDF API

URL to PDF generator API to generate PDF file of a Website or Webpage from a URL.

<mark style="color:green;">`POST`</mark> `https://api.htmlcsstoimg.com/api/v1/generatePdf`

Generates a PDF file from a Web URL or generates a PDF from HTML & CSS

#### Headers

| Name                                             | Type   | Description                                                    |
| ------------------------------------------------ | ------ | -------------------------------------------------------------- |
| CLIENT-API-KEY<mark style="color:red;">\*</mark> | String | API Key for your account. Will be available on your dashboard. |

**Request Body**

<table><thead><tr><th width="269">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>paperWidth</td><td>number</td><td>With of the paper of PDF. (optional with paper_size in px), </td></tr><tr><td>paperHeight</td><td>number</td><td>Height of the paper of PDF.(optional with paper_size in px),</td></tr><tr><td>paper_size</td><td></td><td>Size of the paper, Any out of [‘A3’, ‘A4’, ‘A5’, ‘Letter’, ‘Legal’]. (Optional with width and height),</td></tr><tr><td>url</td><td>String</td><td>URL of the Webpage whose PDF is to be generated.</td></tr><tr><td>html_content</td><td>String</td><td>HTML Content to be used for PDF generation.</td></tr><tr><td>css_content</td><td>String</td><td>CSS Content to be used for PDF generation</td></tr><tr><td>generate_pdf_url</td><td>Boolean</td><td>Whether the output should return the image or the PDF URL. Default value is true.</td></tr><tr><td>wait_till</td><td>Number</td><td>Number of seconds to wait before capturing a screenshot from the URL. Default value is 0.</td></tr><tr><td>landscape</td><td>Boolean</td><td>Page orientation where the content is formatted horizontally. By default the page orientation is Portrait.(default : false)</td></tr><tr><td>displayHeaderFooter</td><td>Boolean</td><td>Generated PDF with have header and Footer on each page.(default=false)</td></tr><tr><td>printBackground</td><td>Boolean</td><td>Prints any background colors or images used on the web page to the PDF. Its default value is true.</td></tr><tr><td>preferCSSPageSize</td><td>Boolean</td><td>Get size from CSS styles.(default=True))</td></tr></tbody></table>
