curl --request POST \
--url https://vortexpdf.com/api/v1/renderers/pdf \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"parts": [
"https://example.com",
"<h1>Hello World</h1>",
{
"content": "<div>Structured HTML content</div>",
"type": "html"
},
{
"content": {
"context": {
"customer_name": "Acme Inc."
},
"template_id": "invoice_template"
},
"type": "template"
}
],
"emulate_media_type": "print",
"footer_template": "<string>",
"header_template": "<string>",
"include_backgrounds": true,
"margin": {
"bottom": 10,
"left": 10,
"right": 10,
"top": 10,
"unit": "mm"
},
"orientation": "portrait",
"output_format": "pdf/a",
"pages": "",
"prefer_css_page_size": false,
"render_header_footer": false,
"scale": 1,
"size": "a4",
"output_encoding": "binary"
}
'import requests
url = "https://vortexpdf.com/api/v1/renderers/pdf"
payload = {
"parts": [
"https://example.com",
"<h1>Hello World</h1>",
{
"content": "<div>Structured HTML content</div>",
"type": "html"
},
{
"content": {
"context": { "customer_name": "Acme Inc." },
"template_id": "invoice_template"
},
"type": "template"
}
],
"emulate_media_type": "print",
"footer_template": "<string>",
"header_template": "<string>",
"include_backgrounds": True,
"margin": {
"bottom": 10,
"left": 10,
"right": 10,
"top": 10,
"unit": "mm"
},
"orientation": "portrait",
"output_format": "pdf/a",
"pages": "",
"prefer_css_page_size": False,
"render_header_footer": False,
"scale": 1,
"size": "a4",
"output_encoding": "binary"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
parts: [
'https://example.com',
'<h1>Hello World</h1>',
{content: '<div>Structured HTML content</div>', type: 'html'},
{
content: {context: {customer_name: 'Acme Inc.'}, template_id: 'invoice_template'},
type: 'template'
}
],
emulate_media_type: 'print',
footer_template: '<string>',
header_template: '<string>',
include_backgrounds: true,
margin: {bottom: 10, left: 10, right: 10, top: 10, unit: 'mm'},
orientation: 'portrait',
output_format: 'pdf/a',
pages: '',
prefer_css_page_size: false,
render_header_footer: false,
scale: 1,
size: 'a4',
output_encoding: 'binary'
})
};
fetch('https://vortexpdf.com/api/v1/renderers/pdf', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://vortexpdf.com/api/v1/renderers/pdf",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'parts' => [
'https://example.com',
'<h1>Hello World</h1>',
[
'content' => '<div>Structured HTML content</div>',
'type' => 'html'
],
[
'content' => [
'context' => [
'customer_name' => 'Acme Inc.'
],
'template_id' => 'invoice_template'
],
'type' => 'template'
]
],
'emulate_media_type' => 'print',
'footer_template' => '<string>',
'header_template' => '<string>',
'include_backgrounds' => true,
'margin' => [
'bottom' => 10,
'left' => 10,
'right' => 10,
'top' => 10,
'unit' => 'mm'
],
'orientation' => 'portrait',
'output_format' => 'pdf/a',
'pages' => '',
'prefer_css_page_size' => false,
'render_header_footer' => false,
'scale' => 1,
'size' => 'a4',
'output_encoding' => 'binary'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://vortexpdf.com/api/v1/renderers/pdf"
payload := strings.NewReader("{\n \"parts\": [\n \"https://example.com\",\n \"<h1>Hello World</h1>\",\n {\n \"content\": \"<div>Structured HTML content</div>\",\n \"type\": \"html\"\n },\n {\n \"content\": {\n \"context\": {\n \"customer_name\": \"Acme Inc.\"\n },\n \"template_id\": \"invoice_template\"\n },\n \"type\": \"template\"\n }\n ],\n \"emulate_media_type\": \"print\",\n \"footer_template\": \"<string>\",\n \"header_template\": \"<string>\",\n \"include_backgrounds\": true,\n \"margin\": {\n \"bottom\": 10,\n \"left\": 10,\n \"right\": 10,\n \"top\": 10,\n \"unit\": \"mm\"\n },\n \"orientation\": \"portrait\",\n \"output_format\": \"pdf/a\",\n \"pages\": \"\",\n \"prefer_css_page_size\": false,\n \"render_header_footer\": false,\n \"scale\": 1,\n \"size\": \"a4\",\n \"output_encoding\": \"binary\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://vortexpdf.com/api/v1/renderers/pdf")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"parts\": [\n \"https://example.com\",\n \"<h1>Hello World</h1>\",\n {\n \"content\": \"<div>Structured HTML content</div>\",\n \"type\": \"html\"\n },\n {\n \"content\": {\n \"context\": {\n \"customer_name\": \"Acme Inc.\"\n },\n \"template_id\": \"invoice_template\"\n },\n \"type\": \"template\"\n }\n ],\n \"emulate_media_type\": \"print\",\n \"footer_template\": \"<string>\",\n \"header_template\": \"<string>\",\n \"include_backgrounds\": true,\n \"margin\": {\n \"bottom\": 10,\n \"left\": 10,\n \"right\": 10,\n \"top\": 10,\n \"unit\": \"mm\"\n },\n \"orientation\": \"portrait\",\n \"output_format\": \"pdf/a\",\n \"pages\": \"\",\n \"prefer_css_page_size\": false,\n \"render_header_footer\": false,\n \"scale\": 1,\n \"size\": \"a4\",\n \"output_encoding\": \"binary\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://vortexpdf.com/api/v1/renderers/pdf")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"parts\": [\n \"https://example.com\",\n \"<h1>Hello World</h1>\",\n {\n \"content\": \"<div>Structured HTML content</div>\",\n \"type\": \"html\"\n },\n {\n \"content\": {\n \"context\": {\n \"customer_name\": \"Acme Inc.\"\n },\n \"template_id\": \"invoice_template\"\n },\n \"type\": \"template\"\n }\n ],\n \"emulate_media_type\": \"print\",\n \"footer_template\": \"<string>\",\n \"header_template\": \"<string>\",\n \"include_backgrounds\": true,\n \"margin\": {\n \"bottom\": 10,\n \"left\": 10,\n \"right\": 10,\n \"top\": 10,\n \"unit\": \"mm\"\n },\n \"orientation\": \"portrait\",\n \"output_format\": \"pdf/a\",\n \"pages\": \"\",\n \"prefer_css_page_size\": false,\n \"render_header_footer\": false,\n \"scale\": 1,\n \"size\": \"a4\",\n \"output_encoding\": \"binary\"\n}"
response = http.request(request)
puts response.read_body{
"data": "JVBERi0xLjcKJeLj+C...",
"encoding": "base64"
}{
"error": "unauthorized",
"message": "Authentication required to access this resource"
}{
"error": "unauthorized",
"message": "Authentication required to access this resource"
}{
"error": {
"message": "<string>"
}
}{
"errors": [
{
"detail": "null value where string expected",
"source": {
"pointer": "/data/attributes/petName"
},
"title": "Invalid value"
}
]
}Create PDF synchronously
Generate a PDF from one or more content sources and return it directly in the response. Content can be provided as URLs to fetch, raw HTML strings, or a combination of both. The response will contain the generated PDF file.
curl --request POST \
--url https://vortexpdf.com/api/v1/renderers/pdf \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"parts": [
"https://example.com",
"<h1>Hello World</h1>",
{
"content": "<div>Structured HTML content</div>",
"type": "html"
},
{
"content": {
"context": {
"customer_name": "Acme Inc."
},
"template_id": "invoice_template"
},
"type": "template"
}
],
"emulate_media_type": "print",
"footer_template": "<string>",
"header_template": "<string>",
"include_backgrounds": true,
"margin": {
"bottom": 10,
"left": 10,
"right": 10,
"top": 10,
"unit": "mm"
},
"orientation": "portrait",
"output_format": "pdf/a",
"pages": "",
"prefer_css_page_size": false,
"render_header_footer": false,
"scale": 1,
"size": "a4",
"output_encoding": "binary"
}
'import requests
url = "https://vortexpdf.com/api/v1/renderers/pdf"
payload = {
"parts": [
"https://example.com",
"<h1>Hello World</h1>",
{
"content": "<div>Structured HTML content</div>",
"type": "html"
},
{
"content": {
"context": { "customer_name": "Acme Inc." },
"template_id": "invoice_template"
},
"type": "template"
}
],
"emulate_media_type": "print",
"footer_template": "<string>",
"header_template": "<string>",
"include_backgrounds": True,
"margin": {
"bottom": 10,
"left": 10,
"right": 10,
"top": 10,
"unit": "mm"
},
"orientation": "portrait",
"output_format": "pdf/a",
"pages": "",
"prefer_css_page_size": False,
"render_header_footer": False,
"scale": 1,
"size": "a4",
"output_encoding": "binary"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
parts: [
'https://example.com',
'<h1>Hello World</h1>',
{content: '<div>Structured HTML content</div>', type: 'html'},
{
content: {context: {customer_name: 'Acme Inc.'}, template_id: 'invoice_template'},
type: 'template'
}
],
emulate_media_type: 'print',
footer_template: '<string>',
header_template: '<string>',
include_backgrounds: true,
margin: {bottom: 10, left: 10, right: 10, top: 10, unit: 'mm'},
orientation: 'portrait',
output_format: 'pdf/a',
pages: '',
prefer_css_page_size: false,
render_header_footer: false,
scale: 1,
size: 'a4',
output_encoding: 'binary'
})
};
fetch('https://vortexpdf.com/api/v1/renderers/pdf', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://vortexpdf.com/api/v1/renderers/pdf",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'parts' => [
'https://example.com',
'<h1>Hello World</h1>',
[
'content' => '<div>Structured HTML content</div>',
'type' => 'html'
],
[
'content' => [
'context' => [
'customer_name' => 'Acme Inc.'
],
'template_id' => 'invoice_template'
],
'type' => 'template'
]
],
'emulate_media_type' => 'print',
'footer_template' => '<string>',
'header_template' => '<string>',
'include_backgrounds' => true,
'margin' => [
'bottom' => 10,
'left' => 10,
'right' => 10,
'top' => 10,
'unit' => 'mm'
],
'orientation' => 'portrait',
'output_format' => 'pdf/a',
'pages' => '',
'prefer_css_page_size' => false,
'render_header_footer' => false,
'scale' => 1,
'size' => 'a4',
'output_encoding' => 'binary'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://vortexpdf.com/api/v1/renderers/pdf"
payload := strings.NewReader("{\n \"parts\": [\n \"https://example.com\",\n \"<h1>Hello World</h1>\",\n {\n \"content\": \"<div>Structured HTML content</div>\",\n \"type\": \"html\"\n },\n {\n \"content\": {\n \"context\": {\n \"customer_name\": \"Acme Inc.\"\n },\n \"template_id\": \"invoice_template\"\n },\n \"type\": \"template\"\n }\n ],\n \"emulate_media_type\": \"print\",\n \"footer_template\": \"<string>\",\n \"header_template\": \"<string>\",\n \"include_backgrounds\": true,\n \"margin\": {\n \"bottom\": 10,\n \"left\": 10,\n \"right\": 10,\n \"top\": 10,\n \"unit\": \"mm\"\n },\n \"orientation\": \"portrait\",\n \"output_format\": \"pdf/a\",\n \"pages\": \"\",\n \"prefer_css_page_size\": false,\n \"render_header_footer\": false,\n \"scale\": 1,\n \"size\": \"a4\",\n \"output_encoding\": \"binary\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://vortexpdf.com/api/v1/renderers/pdf")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"parts\": [\n \"https://example.com\",\n \"<h1>Hello World</h1>\",\n {\n \"content\": \"<div>Structured HTML content</div>\",\n \"type\": \"html\"\n },\n {\n \"content\": {\n \"context\": {\n \"customer_name\": \"Acme Inc.\"\n },\n \"template_id\": \"invoice_template\"\n },\n \"type\": \"template\"\n }\n ],\n \"emulate_media_type\": \"print\",\n \"footer_template\": \"<string>\",\n \"header_template\": \"<string>\",\n \"include_backgrounds\": true,\n \"margin\": {\n \"bottom\": 10,\n \"left\": 10,\n \"right\": 10,\n \"top\": 10,\n \"unit\": \"mm\"\n },\n \"orientation\": \"portrait\",\n \"output_format\": \"pdf/a\",\n \"pages\": \"\",\n \"prefer_css_page_size\": false,\n \"render_header_footer\": false,\n \"scale\": 1,\n \"size\": \"a4\",\n \"output_encoding\": \"binary\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://vortexpdf.com/api/v1/renderers/pdf")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"parts\": [\n \"https://example.com\",\n \"<h1>Hello World</h1>\",\n {\n \"content\": \"<div>Structured HTML content</div>\",\n \"type\": \"html\"\n },\n {\n \"content\": {\n \"context\": {\n \"customer_name\": \"Acme Inc.\"\n },\n \"template_id\": \"invoice_template\"\n },\n \"type\": \"template\"\n }\n ],\n \"emulate_media_type\": \"print\",\n \"footer_template\": \"<string>\",\n \"header_template\": \"<string>\",\n \"include_backgrounds\": true,\n \"margin\": {\n \"bottom\": 10,\n \"left\": 10,\n \"right\": 10,\n \"top\": 10,\n \"unit\": \"mm\"\n },\n \"orientation\": \"portrait\",\n \"output_format\": \"pdf/a\",\n \"pages\": \"\",\n \"prefer_css_page_size\": false,\n \"render_header_footer\": false,\n \"scale\": 1,\n \"size\": \"a4\",\n \"output_encoding\": \"binary\"\n}"
response = http.request(request)
puts response.read_body{
"data": "JVBERi0xLjcKJeLj+C...",
"encoding": "base64"
}{
"error": "unauthorized",
"message": "Authentication required to access this resource"
}{
"error": "unauthorized",
"message": "Authentication required to access this resource"
}{
"error": {
"message": "<string>"
}
}{
"errors": [
{
"detail": "null value where string expected",
"source": {
"pointer": "/data/attributes/petName"
},
"title": "Invalid value"
}
]
}Authorizations
Manage your API keys at https://vortexpdf.com/api-keys
Body
Render options
Options for synchronous PDF rendering, where the PDF is returned directly in the API response.
An array of content parts to render into a single PDF. Each part can be a URL string, HTML content string, or a structured content object with type and content.
1 - 50 elementsA content part that can be a URL string, HTML string, or a structured content object.
^https?://\S+[
"https://example.com",
"<h1>Hello World</h1>",
{
"content": "<div>Structured HTML content</div>",
"type": "html"
},
{
"content": {
"context": { "customer_name": "Acme Inc." },
"template_id": "invoice_template"
},
"type": "template"
}
]
Emulates the specified media type during rendering. Use 'screen' for web display styles or 'print' for print-optimized styles. Particularly useful for pages with different CSS for screen and print media queries.
screen, print Evaluates a JavaScript expression in the page context before rendering. Useful for manipulating the DOM, triggering actions, or waiting for dynamic content to load. If the expression returns a Promise, rendering will wait for it to resolve.
Show child attributes
Show child attributes
HTML template for the page footer. Supports special classes like 'date', 'title', 'url', 'pageNumber', and 'totalPages' for dynamic content.
HTML template for the page header. Supports special classes like 'date', 'title', 'url', 'pageNumber', and 'totalPages' for dynamic content.
Whether to include background images and colors in the rendered PDF. Set to false to optimize for printing or reduce file size.
Document margins specification with unit. Controls the space between the page edges and content.
Show child attributes
Show child attributes
{
"bottom": 10,
"left": 10,
"right": 10,
"top": 10,
"unit": "mm"
}
Page orientation for the PDF. 'portrait' is taller than wide, 'landscape' is wider than tall.
portrait, landscape Output file format. 'pdf/a' is PDF/A-2b compliant for archiving, while 'pdf' is standard PDF.
pdf/a, pdf Specifies which pages to include in the output using a comma-separated list of page ranges (e.g., '1-5, 8, 11-13'). Uses one-based indexing. Pages will be included in the document's natural order regardless of the specified range, and each page will only be included once. An empty string includes all pages.
^$|^(\d+(-\d+)?)(,\s*(\d+(-\d+)?))*$Whether to prioritize page size defined in CSS using @page rules. When true, CSS page size takes precedence over the 'size' parameter. When false, content will be scaled to fit the specified paper size.
Whether to render the header and footer templates on each page. Must be true for header_template and footer_template to take effect.
Scale factor for the webpage rendering. Values below 1.0 reduce size, above 1.0 enlarge content.
0.1 <= x <= 2Sets a cookie before rendering, useful for authenticated content or personalized views.
Show child attributes
Show child attributes
Standard document size preset name.
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, letter, legal, tabloid, ledger "a4"
Waits for a specific element attribute to be set before rendering, useful for ensuring dynamic content is fully loaded.
Show child attributes
Show child attributes
Specifies how the PDF should be encoded in the response. 'binary' returns raw bytes, while 'base64' returns a base64-encoded string.
binary, base64 Response
Render succeeded
Binary PDF file