pdforge
API Reference
API Reference
  • Getting started
    • Overview
    • Authentication
    • Rate limit
  • PDFs from templates
    • Asynchronous request
    • Synchronous request
  • Html to pdf conversion
    • Asynchronous request
    • Synchronous request
  • OPTIONS
    • How render PNG instead of PDF
    • Storage Options (s3)
    • PDF Params
Powered by GitBook
On this page
  • When to use it
  • How to use it
  1. Html to pdf conversion

Synchronous request

Synchronous means that when calling the API the request will wait for the pdf file to be generated before returning a response.

When to use it

Synchronous requests are useful when you want to get the results back immediately.

It is usually easier to use synchronous requests when integrating with no-code solutions such as Zapier.

If your server environment can deal with potentially having many long running connections open at the same time, then synchronous requests might be a good choice.

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/sync

Body params:

Name
Type
Description

html (required)

string

The HTML content you want to render

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 the templateId parameter.

If your template has variables, it's also required to send the data object with your variables.

Request:

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

This endpoint responds with 200 OK once the pdf has been generated with the following body:

{
    "signedUrl": "https://pdforge-production.s3.us-east-2.amazonaws.com/..."
}

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.

PreviousAsynchronous requestNextHow render PNG instead of PDF

Last updated 14 days ago

The object containing the parameters for your PDF. .

See all the options here