Skip to Content
Preview PDF

Preview PDF

Send a POST request to this endpoint to print your HTML as a PDF without storing it. The response is the PDF itself, stamped “Preview” on every page.

You will need to authenticate to use this API. See authentication.

A preview costs no credits and is not stored. You can send 30 previews per hour. To keep the PDF at a link, use Create PDF from HTML.

Request

POST https://api.ojo.so/v1/pdf/preview

Headers

HeaderValueDescription
Content-Typetext/htmlSpecify that the request body contains HTML

Request Body

The request body should contain the HTML you want to print. Page size and margins follow the same rules as in Create PDF from HTML.

curl --request POST \ --url https://api.ojo.so/v1/pdf/preview \ --header 'Authorization: Bearer <your API key>' \ --header 'Content-Type: text/html' \ --data '<html><body><h1>Invoice #1024</h1><p>Total: $120.00</p></body></html>' \ --output preview.pdf

Response

The PDF, as application/pdf. X-Pdf-Pages gives the number of pages. X-Render-Warnings lists the resources the page could not load, as a percent-encoded JSON array of strings, and is left out when there were none.

HTTP/1.1 200 OK Content-Type: application/pdf X-Pdf-Pages: 2 <the PDF>