Asynchronous request
Asynchronous means that the request will return immediately with a requestId (if the request passes validation), but the pdf file will be sent after a few seconds to your custom webhook.
When to use it
Asynchronous requests are useful when you want to generate a large number of pdf reports or if you don't want to block your user experience while the pdf is being generated.
You can fire off the requests and wait for your webhook endpoint to be called with the requestId
.
We recommend using Asynchronous requests for a better performance on your application.
How to use it
Send a POST request to https://api.pdforge.com/v1/html-to-pdf/async
Body params:
html
(required)
string
The HTML content you want to render
webhook
(required)
string
The url of your webook
pdfParams
object
convertToImage
boolean
If true, will return a .PNG file instead of a .PDF file (default: false)
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)
The endpoint accepts only JSON data.
It's required to send both the html
and webhook
parameters.
Request:
This endpoint responds with 200 OK
immediately with a renderId
, with the following response body:
After a few seconds, the pdf file will be generated and we will send a POST to your webhook with the following body:
The renderStatus could be either SUCCESS
or FAILED.
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.
Last updated