cURL
Python
Java
curl -X POST https://sandbox.pdfmotor.net/v1/render \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_DEMO_KEY" \
-d '{
"template": "default",
"title": "Demo PDF",
"subtitle": "Generated via PDF Motor",
"fields": [
{ "label": "Name", "value": "John Doe" },
{ "label": "Email", "value": "john@example.com" }
]
}' \
-o document.pdf
import requests
url = "https://sandbox.pdfmotor.net/v1/render"
headers = {
"Content-Type": "application/json",
"X-API-Key": "YOUR_DEMO_KEY"
}
payload = {
"template": "default",
"title": "Demo PDF",
"subtitle": "Generated via PDF Motor",
"fields": [
{ "label": "Name", "value": "John Doe" },
{ "label": "Email", "value": "john@example.com" }
]
}
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
with open("document.pdf", "wb") as f:
f.write(response.content)
print("PDF generated: document.pdf")
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
public class Example {
public static void main(String[] args) throws Exception {
String json = "{" +
"\"template\":\"default\"," +
"\"title\":\"Damage Report\"," +
"\"subtitle\":\"Date: 2026-01-10\"," +
"\"fields\":[" +
" {\"label\":\"Name\",\"value\":\"John Doe\"}," +
" {\"label\":\"Email\",\"value\":\"john@example.com\"}," +
" {\"label\":\"Damage Type\",\"value\":\"Water damage\"}" +
"]," +
"\"footer\":\"Generated with PDF Motor\"" +
"}";
URL url = new URL("https://sandbox.pdfmotor.net/v1/render");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("X-API-Key", "YOUR_DEMO_KEY");
con.setDoOutput(true);
try (OutputStream os = con.getOutputStream()) {
os.write(json.getBytes(StandardCharsets.UTF_8));
}
int status = con.getResponseCode();
System.out.println("HTTP Status: " + status);
if (status != 200) {
throw new RuntimeException("HTTP error: " + status);
}
try (InputStream is = con.getInputStream()) {
Files.copy(
is,
Path.of("document.pdf"),
java.nio.file.StandardCopyOption.REPLACE_EXISTING
);
}
System.out.println("PDF generated: document.pdf");
}
}