Skip to main content
We recommend using asynchronous requests for better performance on your application.
POST https://api.pdfnoodle.com/v1/html-to-pdf/sync

Request

curl --location 'https://api.pdfnoodle.com/v1/html-to-pdf/sync' \
--header 'Authorization: Bearer pdfnoodle_api_123456789' \
--header 'Content-Type: application/json' \
--data '{
    "html": "<html><body><h1>Your HTML here!</h1></body></html>"
}'

Response

{
  "signedUrl": "https://pdforge-production.s3.us-east-2.amazonaws.com/...",
  "metadata": {
    "executionTime": "1.805 seconds",
    "fileSize": "4.066 kB"
  }
}
This endpoint responds with 200 OK once the PDF has been generated. The response body will contain a signedUrl key which is a temporary URL pointing to the generated PDF file on our S3 bucket. If you passed a custom s3_bucket, it’ll be stored there instead. This URL will expire after 1 hour. If your PDF takes more than 30 seconds to render, it will automatically be added to an asynchronous queue and you’ll receive a 202 Accepted response with a requestId. You can check the status using the Get PDF Status endpoint.

PDF Render Metadata

We’ll also bring some additional metadata from your PDF render with every response:
  • executionTime - Time in seconds it took to generate your PDF
  • fileSize - PDF size in kiloBytes

Parameters

html
string
required
The HTML content you want to render
pdfParams
object
The object containing the parameters for your PDF. See all the options here.
convertToImage
boolean
If true, will return a .PNG file instead of a .PDF file (default: false)
metadata
object
This object containing the metadata for your PDF. See all the options here.
s3_bucket
string
The id of the active s3 connection you want to store your generated file on. (only available in the high plan)
s3_key
string
The path, including subdirectories and the filename without extension, to use when saving the render in your S3 bucket. (only available if being stored in custom s3_bucket)
hasCover
boolean
If true, will hide the footer and the header elements on the first page of the generated PDF. (default: false)

Request Timeout (>30 seconds)

Synchronous requests are useful when you want to get the results back immediately. However, if your PDF takes more than 30 seconds to render, it will automatically be added to an asynchronous queue.
Sometimes, your PDF might take more than 30 seconds to render, if it has a lot of heavy images/charts and a lot of pages being generated. If that’s the case and your PDF takes more than 30 seconds to render synchronously, we’ll automatically add it to an asynchronous queue to render it. You’ll be able to check if the PDF is completed using the Get PDF Status endpoint with the requestId you just received (or just by making a GET request on the statusUrl). If the PDF is still rendering, you’ll get a response like this:
{
  "requestId": "pdfnoodle_request_123456789",
  "renderStatus": "ONGOING",
  "signedUrl": "",
  "metadata": {}
}
And once the PDF is ready, you’ll receive a response like this:
{
  "requestId": "pdfnoodle_request_123456789",
  "renderStatus": "SUCCESS",
  "signedUrl": "https://pdforge-production.s3.us-east-2.amazonaws.com/...",
  "metadata": {
    "executionTime": "1.805 seconds",
    "fileSize": "4.066 kB"
  }
}