JavaScript
import Sudopdf from '@sudopdf/sdk';
const client = new Sudopdf({
apiKey: 'My API Key', // process.env['SUDOPDF_API_KEY'] is the default and can be omitted.
});
const response = await client.pdf.generate({
templateId: 22
data: { foo: 'bar' }
});
console.log(response.data);curl --request POST \
--url http://app.sudopdf.com/api/v1/pdf/generate \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"data": {},
"templateId": "<string>",
"url": "<string>",
"html": "<string>",
"metadata": {},
"renderOptions": {
"path": "<string>",
"scale": 1,
"displayHeaderFooter": true,
"headerTemplate": "<string>",
"footerTemplate": "<string>",
"printBackground": true,
"landscape": true,
"pageRanges": "<string>",
"width": "<string>",
"height": "<string>",
"margin": {
"top": "<string>",
"right": "<string>",
"bottom": "<string>",
"left": "<string>"
},
"preferCSSPageSize": true,
"timeout": 123,
"omitBackground": true
}
}
'import requests
url = "http://app.sudopdf.com/api/v1/pdf/generate"
payload = {
"data": {},
"templateId": "<string>",
"url": "<string>",
"html": "<string>",
"metadata": {},
"renderOptions": {
"path": "<string>",
"scale": 1,
"displayHeaderFooter": True,
"headerTemplate": "<string>",
"footerTemplate": "<string>",
"printBackground": True,
"landscape": True,
"pageRanges": "<string>",
"width": "<string>",
"height": "<string>",
"margin": {
"top": "<string>",
"right": "<string>",
"bottom": "<string>",
"left": "<string>"
},
"preferCSSPageSize": True,
"timeout": 123,
"omitBackground": True
}
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "http://app.sudopdf.com/api/v1/pdf/generate",
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([
'data' => [
],
'templateId' => '<string>',
'url' => '<string>',
'html' => '<string>',
'metadata' => [
],
'renderOptions' => [
'path' => '<string>',
'scale' => 1,
'displayHeaderFooter' => true,
'headerTemplate' => '<string>',
'footerTemplate' => '<string>',
'printBackground' => true,
'landscape' => true,
'pageRanges' => '<string>',
'width' => '<string>',
'height' => '<string>',
'margin' => [
'top' => '<string>',
'right' => '<string>',
'bottom' => '<string>',
'left' => '<string>'
],
'preferCSSPageSize' => true,
'timeout' => 123,
'omitBackground' => true
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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 := "http://app.sudopdf.com/api/v1/pdf/generate"
payload := strings.NewReader("{\n \"data\": {},\n \"templateId\": \"<string>\",\n \"url\": \"<string>\",\n \"html\": \"<string>\",\n \"metadata\": {},\n \"renderOptions\": {\n \"path\": \"<string>\",\n \"scale\": 1,\n \"displayHeaderFooter\": true,\n \"headerTemplate\": \"<string>\",\n \"footerTemplate\": \"<string>\",\n \"printBackground\": true,\n \"landscape\": true,\n \"pageRanges\": \"<string>\",\n \"width\": \"<string>\",\n \"height\": \"<string>\",\n \"margin\": {\n \"top\": \"<string>\",\n \"right\": \"<string>\",\n \"bottom\": \"<string>\",\n \"left\": \"<string>\"\n },\n \"preferCSSPageSize\": true,\n \"timeout\": 123,\n \"omitBackground\": true\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
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("http://app.sudopdf.com/api/v1/pdf/generate")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {},\n \"templateId\": \"<string>\",\n \"url\": \"<string>\",\n \"html\": \"<string>\",\n \"metadata\": {},\n \"renderOptions\": {\n \"path\": \"<string>\",\n \"scale\": 1,\n \"displayHeaderFooter\": true,\n \"headerTemplate\": \"<string>\",\n \"footerTemplate\": \"<string>\",\n \"printBackground\": true,\n \"landscape\": true,\n \"pageRanges\": \"<string>\",\n \"width\": \"<string>\",\n \"height\": \"<string>\",\n \"margin\": {\n \"top\": \"<string>\",\n \"right\": \"<string>\",\n \"bottom\": \"<string>\",\n \"left\": \"<string>\"\n },\n \"preferCSSPageSize\": true,\n \"timeout\": 123,\n \"omitBackground\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://app.sudopdf.com/api/v1/pdf/generate")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {},\n \"templateId\": \"<string>\",\n \"url\": \"<string>\",\n \"html\": \"<string>\",\n \"metadata\": {},\n \"renderOptions\": {\n \"path\": \"<string>\",\n \"scale\": 1,\n \"displayHeaderFooter\": true,\n \"headerTemplate\": \"<string>\",\n \"footerTemplate\": \"<string>\",\n \"printBackground\": true,\n \"landscape\": true,\n \"pageRanges\": \"<string>\",\n \"width\": \"<string>\",\n \"height\": \"<string>\",\n \"margin\": {\n \"top\": \"<string>\",\n \"right\": \"<string>\",\n \"bottom\": \"<string>\",\n \"left\": \"<string>\"\n },\n \"preferCSSPageSize\": true,\n \"timeout\": 123,\n \"omitBackground\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"mode": "sync",
"message": "PDF generated successfully",
"environment": "production",
"data": {
"url": "https://app.sudopdf.com/files/abc123.pdf",
"creditsUsed": 1
}
}
Endpoints
Generate PDF
Generate a single PDF
POST
/
pdf
/
generate
JavaScript
import Sudopdf from '@sudopdf/sdk';
const client = new Sudopdf({
apiKey: 'My API Key', // process.env['SUDOPDF_API_KEY'] is the default and can be omitted.
});
const response = await client.pdf.generate({
templateId: 22
data: { foo: 'bar' }
});
console.log(response.data);curl --request POST \
--url http://app.sudopdf.com/api/v1/pdf/generate \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"data": {},
"templateId": "<string>",
"url": "<string>",
"html": "<string>",
"metadata": {},
"renderOptions": {
"path": "<string>",
"scale": 1,
"displayHeaderFooter": true,
"headerTemplate": "<string>",
"footerTemplate": "<string>",
"printBackground": true,
"landscape": true,
"pageRanges": "<string>",
"width": "<string>",
"height": "<string>",
"margin": {
"top": "<string>",
"right": "<string>",
"bottom": "<string>",
"left": "<string>"
},
"preferCSSPageSize": true,
"timeout": 123,
"omitBackground": true
}
}
'import requests
url = "http://app.sudopdf.com/api/v1/pdf/generate"
payload = {
"data": {},
"templateId": "<string>",
"url": "<string>",
"html": "<string>",
"metadata": {},
"renderOptions": {
"path": "<string>",
"scale": 1,
"displayHeaderFooter": True,
"headerTemplate": "<string>",
"footerTemplate": "<string>",
"printBackground": True,
"landscape": True,
"pageRanges": "<string>",
"width": "<string>",
"height": "<string>",
"margin": {
"top": "<string>",
"right": "<string>",
"bottom": "<string>",
"left": "<string>"
},
"preferCSSPageSize": True,
"timeout": 123,
"omitBackground": True
}
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "http://app.sudopdf.com/api/v1/pdf/generate",
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([
'data' => [
],
'templateId' => '<string>',
'url' => '<string>',
'html' => '<string>',
'metadata' => [
],
'renderOptions' => [
'path' => '<string>',
'scale' => 1,
'displayHeaderFooter' => true,
'headerTemplate' => '<string>',
'footerTemplate' => '<string>',
'printBackground' => true,
'landscape' => true,
'pageRanges' => '<string>',
'width' => '<string>',
'height' => '<string>',
'margin' => [
'top' => '<string>',
'right' => '<string>',
'bottom' => '<string>',
'left' => '<string>'
],
'preferCSSPageSize' => true,
'timeout' => 123,
'omitBackground' => true
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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 := "http://app.sudopdf.com/api/v1/pdf/generate"
payload := strings.NewReader("{\n \"data\": {},\n \"templateId\": \"<string>\",\n \"url\": \"<string>\",\n \"html\": \"<string>\",\n \"metadata\": {},\n \"renderOptions\": {\n \"path\": \"<string>\",\n \"scale\": 1,\n \"displayHeaderFooter\": true,\n \"headerTemplate\": \"<string>\",\n \"footerTemplate\": \"<string>\",\n \"printBackground\": true,\n \"landscape\": true,\n \"pageRanges\": \"<string>\",\n \"width\": \"<string>\",\n \"height\": \"<string>\",\n \"margin\": {\n \"top\": \"<string>\",\n \"right\": \"<string>\",\n \"bottom\": \"<string>\",\n \"left\": \"<string>\"\n },\n \"preferCSSPageSize\": true,\n \"timeout\": 123,\n \"omitBackground\": true\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
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("http://app.sudopdf.com/api/v1/pdf/generate")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {},\n \"templateId\": \"<string>\",\n \"url\": \"<string>\",\n \"html\": \"<string>\",\n \"metadata\": {},\n \"renderOptions\": {\n \"path\": \"<string>\",\n \"scale\": 1,\n \"displayHeaderFooter\": true,\n \"headerTemplate\": \"<string>\",\n \"footerTemplate\": \"<string>\",\n \"printBackground\": true,\n \"landscape\": true,\n \"pageRanges\": \"<string>\",\n \"width\": \"<string>\",\n \"height\": \"<string>\",\n \"margin\": {\n \"top\": \"<string>\",\n \"right\": \"<string>\",\n \"bottom\": \"<string>\",\n \"left\": \"<string>\"\n },\n \"preferCSSPageSize\": true,\n \"timeout\": 123,\n \"omitBackground\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://app.sudopdf.com/api/v1/pdf/generate")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {},\n \"templateId\": \"<string>\",\n \"url\": \"<string>\",\n \"html\": \"<string>\",\n \"metadata\": {},\n \"renderOptions\": {\n \"path\": \"<string>\",\n \"scale\": 1,\n \"displayHeaderFooter\": true,\n \"headerTemplate\": \"<string>\",\n \"footerTemplate\": \"<string>\",\n \"printBackground\": true,\n \"landscape\": true,\n \"pageRanges\": \"<string>\",\n \"width\": \"<string>\",\n \"height\": \"<string>\",\n \"margin\": {\n \"top\": \"<string>\",\n \"right\": \"<string>\",\n \"bottom\": \"<string>\",\n \"left\": \"<string>\"\n },\n \"preferCSSPageSize\": true,\n \"timeout\": 123,\n \"omitBackground\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"mode": "sync",
"message": "PDF generated successfully",
"environment": "production",
"data": {
"url": "https://app.sudopdf.com/files/abc123.pdf",
"creditsUsed": 1
}
}
Query Parameters
Body
application/json
PDF to generate
Response
PDF generation response
Unified PDF generation success response
⌘I