# PDFBolt - Scalable and Privacy‑First PDF Generation API
> PDFBolt API - generate professional PDFs from HTML, URLs, and dynamic templates using REST endpoints. Supports Node.js, Python, Java, PHP, C#, Go, Rust with Direct/Sync/Async modes, Handlebars templates, direct S3 uploads, team collaboration, GDPR compliance, and enterprise-grade privacy.
This file contains all documentation content in a single document following the llmstxt.org standard.
## Introduction
🎉 Welcome to the PDFBolt API!
For quick setup instructions, head over to the [Quick Start Guide](/docs/quick-start-guide). Continue
reading to explore the [API Endpoints](/docs/api-endpoints), fine‑tune [Parameters](/docs/parameters), create dynamic [Templates](/docs/pdf-templates), and uncover best practices to maximize the
efficiency of our powerful PDF generation API. Let's get started and transform the way
you handle documents!
## Overview
PDFBolt is a robust PDF generation API that converts HTML content, web pages, and dynamic templates into **high-quality PDFs**. It’s designed for scalability, security, ease of use, and reliability – making it ideal for developers and businesses who need a fast, flexible, and cost-effective way to generate PDFs from various sources.
## Purpose and Benefits
* Built to make PDF generation simple and accessible, PDFBolt offers a streamlined integration process with powerful templating capabilities that separate design from data.
* Like Stripe for payment processing, PDFBolt aspires to be equally developer-friendly in document generation,
supporting various business sizes and needs.
* Privacy is a top priority at PDFBolt, ensuring data is handled securely throughout every step of the conversion
process.
## Key Features
- High-quality PDF rendering with [synchronous](/docs/api-endpoints/sync) and [asynchronous](/docs/api-endpoints/async) options.
- **Dynamic template functionality** with Handlebars support for reusable PDF layouts (more details in the [Templates](/docs/pdf-templates) section).
- Intuitive Admin Dashboard for monitoring usage and managing account settings (more details in the [Admin Dashboard](/docs/admin-dashboard) section).
- API with clear, user-friendly documentation that enables integration across multiple languages.
- Cost-efficient [pricing plans](/#pricing-plans) suitable for small and large-scale requirements.
🚀 Ready to transform your workflows? Get started with PDFBolt today!
---
## Quick Start Guide
Below is a **step-by-step guide** to get up and running with PDFBolt's **PDF generation API** quickly. Test with cURL or Postman, or integrate using Node.js, Python, Java, PHP, C#, Go, Rust.
### 1. Sign Up and Get Your API Key
Start by [signing up](https://app.pdfbolt.com/register) for an account. Once registered, you'll find your unique API key in the Admin Dashboard under the **API Keys** section. Every new user is automatically enrolled in our **free plan**, which provides **100 document conversions per month** to explore PDFBolt’s features.
For more details on managing API keys, visit the Admin Dashboard [API Keys](/docs/admin-dashboard/api-keys) section.
:::tip Quick API Testing with Postman 🚀
- Use our Postman collection and start testing API requests in seconds!
- For detailed instructions, check out our [Quick Start Guide for Postman](/docs/quick-start-guide/postman).
**Click the button below to get started:**
[](https://app.getpostman.com/run-collection/40399365-9472b2d4-c8da-4338-8774-962cc6bb9347?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D40399365-9472b2d4-c8da-4338-8774-962cc6bb9347%26entityType%3Dcollection%26workspaceId%3D3a6b1d25-d352-4c2e-8a9b-0b4fcb6d6cae#?env%5BPDFBolt%5D=W3sia2V5IjoiYmFzZV91cmwiLCJ2YWx1ZSI6Imh0dHBzOi8vYXBpLnBkZmJvbHQuY29tIiwiZW5hYmxlZCI6dHJ1ZSwidHlwZSI6ImRlZmF1bHQiLCJzZXNzaW9uVmFsdWUiOiJodHRwczovL2FwaS5wZGZib2x0LmNvbSIsImNvbXBsZXRlU2Vzc2lvblZhbHVlIjoiaHR0cHM6Ly9hcGkucGRmYm9sdC5jb20iLCJzZXNzaW9uSW5kZXgiOjB9LHsia2V5IjoiQVBJX0tFWSIsInZhbHVlIjoiIiwiZW5hYmxlZCI6dHJ1ZSwidHlwZSI6InNlY3JldCIsInNlc3Npb25WYWx1ZSI6IiIsImNvbXBsZXRlU2Vzc2lvblZhbHVlIjoiIiwic2Vzc2lvbkluZGV4IjoxfSx7ImtleSI6IndlYmhvb2tfdXJsIiwidmFsdWUiOiIiLCJlbmFibGVkIjp0cnVlLCJ0eXBlIjoiZGVmYXVsdCIsInNlc3Npb25WYWx1ZSI6IiIsImNvbXBsZXRlU2Vzc2lvblZhbHVlIjoiIiwic2Vzc2lvbkluZGV4IjoyfSx7ImtleSI6ImN1c3RvbVMzX3VybCIsInZhbHVlIjoiIiwiZW5hYmxlZCI6dHJ1ZSwidHlwZSI6ImRlZmF1bHQiLCJzZXNzaW9uVmFsdWUiOiIiLCJjb21wbGV0ZVNlc3Npb25WYWx1ZSI6IiIsInNlc3Npb25JbmRleCI6M31d)
:::
### 2. Set Up Authorization
Securely access PDFBolt's API by including your unique `API-KEY` in the headers of your REST API requests:
```bash
API-KEY: YOUR-API-KEY
```
### 3. Make Your First Request
Choose your preferred endpoint and source combination using cURL.
**➡️ Endpoints:**
The **Direct** endpoint provides immediate PDF generation and returns the raw PDF file in the response.
**➡️ Sources:**
**Convert any webpage into a PDF:**
```bash
curl 'https://api.pdfbolt.com/v1/direct' \
-H 'Content-Type: application/json' \
-H 'API-KEY: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
-d '{
"url": "https://example.com",
"format": "A4",
"printBackground": true
}' \
-o webpage.pdf
```
**Convert HTML content directly into a PDF:**
```bash
curl 'https://api.pdfbolt.com/v1/direct' \
-H 'Content-Type: application/json' \
-H 'API-KEY: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
-d '{
"html": "PGh0bWw+PGJvZHk+PGgxPkhlbGxvITwvaDE+PHA+VGhpcyBpcyBhIHNhbXBsZSBQREYuPC9wPjwvYm9keT48L2h0bWw+",
"margin": {
"top": "30px",
"left": "30px"
}
}' \
-o document.pdf
```
:::note Base64 Explanation
The base64 encoded HTML above represents:
```
Hello!This is a sample PDF.
```
:::
**Use reusable templates for dynamic PDF generation:**
```bash
curl 'https://api.pdfbolt.com/v1/direct' \
-H 'Content-Type: application/json' \
-H 'API-KEY: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
-d '{
"templateId": "your-template-id",
"templateData": {
"client_name": "John Doe",
"invoice_number": "INV-001",
"total_amount": "$299.99",
"line_items": [
{
"description": "Web Development",
"unit_price": "$200.00"
},
{
"description": "Design Services",
"unit_price": "$99.99"
}
]
}
}' \
-o invoice.pdf
```
:::info New to templates?
Create your first template in the app, then use its ID in your API calls.
**[→ Learn more about Templates](/docs/pdf-templates)**
:::
The **Sync** endpoint returns a JSON response with a download URL for the PDF.
**➡️ Sources:**
**Convert webpage and get download URL:**
```bash
curl 'https://api.pdfbolt.com/v1/sync' \
-H 'Content-Type: application/json' \
-H 'API-KEY: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
-d '{
"url": "https://example.com",
"format": "A4",
"printBackground": true
}'
```
**Convert HTML and get download URL:**
```bash
curl 'https://api.pdfbolt.com/v1/sync' \
-H 'Content-Type: application/json' \
-H 'API-KEY: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
-d '{
"html": "PGh0bWw+PGJvZHk+PGgxPkhlbGxvITwvaDE+PHA+VGhpcyBpcyBhIHNhbXBsZSBQREYuPC9wPjwvYm9keT48L2h0bWw+",
"margin": {
"top": "30px",
"left": "30px"
}
}'
```
**Use templates and get download URL:**
```bash
curl 'https://api.pdfbolt.com/v1/sync' \
-H 'Content-Type: application/json' \
-H 'API-KEY: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
-d '{
"templateId": "your-template-id",
"templateData": {
"client_name": "John Doe",
"invoice_number": "INV-001",
"total_amount": "$299.99",
"line_items": [
{
"description": "Web Development",
"unit_price": "$200.00"
},
{
"description": "Design Services",
"unit_price": "$99.99"
}
]
}
}'
```
The **Async** endpoint processes requests asynchronously and sends results via webhook.
**➡️ Sources:**
**Convert webpage with webhook notification:**
```bash
curl 'https://api.pdfbolt.com/v1/async' \
-H 'Content-Type: application/json' \
-H 'API-KEY: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
-d '{
"url": "https://example.com",
"format": "A4",
"printBackground": true,
"webhook": "https://your-app.com/webhook"
}'
```
**Convert HTML with webhook notification:**
```bash
curl 'https://api.pdfbolt.com/v1/async' \
-H 'Content-Type: application/json' \
-H 'API-KEY: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
-d '{
"html": "PGh0bWw+PGJvZHk+PGgxPkhlbGxvITwvaDE+PHA+VGhpcyBpcyBhIHNhbXBsZSBQREYuPC9wPjwvYm9keT48L2h0bWw+",
"margin": {
"top": "30px",
"left": "30px"
},
"webhook": "https://your-app.com/webhook"
}'
```
**Use templates with webhook notification:**
```bash
curl 'https://api.pdfbolt.com/v1/async' \
-H 'Content-Type: application/json' \
-H 'API-KEY: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' \
-d '{
"templateId": "your-template-id",
"templateData": {
"client_name": "John Doe",
"invoice_number": "INV-001",
"total_amount": "$299.99",
"line_items": [
{
"description": "Web Development",
"unit_price": "$200.00"
},
{
"description": "Design Services",
"unit_price": "$99.99"
}
]
},
"webhook": "https://your-app.com/webhook"
}'
```
### 4. Quick Start for Your Favorite Language and Postman
Ready to get started? Choose your favorite language or tool and follow our tailored step‑by‑step guides to integrate PDFBolt with ease.
---
## Node.js
# Quick Start for Node.js
Both wkhtmltopdf and Puppeteer are well-supported in Node.js, though they can be complex to configure for specific needs. Our PDF generation API provides a quicker, easier way to generate PDFs from HTML, URLs, and dynamic templates. Here's how to start in Node.js.
### 1. Get Your API Key
* After registering, log in to the **Admin Dashboard** and navigate to the **API Keys** section to retrieve your API key.
* Ensure you keep this key secure, as it is essential for authorizing your requests to the PDFBolt API.
### 2. Make Your First Request
Follow these examples below to send basic requests to the PDFBolt API and generate your PDFs effortlessly.
**Choose your preferred endpoint and source combination.**
**➡️ Endpoints:**
The **Direct** endpoint provides immediate PDF generation and returns the raw PDF file in the response.
**➡️ Sources:**
**Convert any webpage into a PDF:**
```js
const fs = require('fs');
async function generatePdf() {
const response = await fetch('https://api.pdfbolt.com/v1/direct', {
method: 'POST',
headers: {
'API-KEY': 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://example.com',
format: 'A4',
printBackground: true
})
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`HTTP ${response.status} - ${errorText}`);
}
const pdfBuffer = await response.arrayBuffer();
fs.writeFileSync('webpage.pdf', Buffer.from(pdfBuffer));
console.log('PDF generated successfully');
}
generatePdf().catch(console.error);
```
**Convert HTML content directly into a PDF** (HTML must be base64 encoded):
```js
const fs = require('fs');
async function generatePdf() {
const htmlContent = 'Hello!This is a sample PDF.';
const base64Html = Buffer.from(htmlContent).toString('base64');
const response = await fetch('https://api.pdfbolt.com/v1/direct', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'API-KEY': 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
},
body: JSON.stringify({
html: base64Html,
margin: {
top: '30px',
left: '30px'
}
})
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`HTTP ${response.status} - ${errorText}`);
}
const pdfBuffer = await response.arrayBuffer();
fs.writeFileSync('document.pdf', Buffer.from(pdfBuffer));
console.log('PDF generated successfully');
}
generatePdf().catch(console.error);
```
**Use reusable templates for dynamic PDF generation:**
```js
const fs = require('fs');
async function generatePdf() {
const response = await fetch('https://api.pdfbolt.com/v1/direct', {
method: 'POST',
headers: {
'API-KEY': 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
'Content-Type': 'application/json'
},
body: JSON.stringify({
templateId: 'your-template-id',
templateData: {
client_name: 'John Doe',
invoice_number: 'INV-001',
total_amount: '$299.99',
line_items: [
{ description: 'Web Development', unit_price: '$200.00' },
{ description: 'Design Services', unit_price: '$99.99' }
]
}
})
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`HTTP ${response.status} - ${errorText}`);
}
const pdfBuffer = await response.arrayBuffer();
fs.writeFileSync('invoice.pdf', Buffer.from(pdfBuffer));
console.log('PDF generated successfully');
}
generatePdf().catch(console.error);
```
:::info New to templates?
Create your first template in the app, then use its ID in your API calls.
**[→ Learn more about Templates](/docs/pdf-templates)**
:::
The **Sync** endpoint returns a JSON response with a download URL for the PDF.
**➡️ Sources:**
**Convert any webpage and get download URL:**
```js
async function generatePdf() {
const response = await fetch('https://api.pdfbolt.com/v1/sync', {
method: 'POST',
headers: {
'API-KEY': 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://example.com',
format: 'A4',
printBackground: true
})
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`HTTP ${response.status} - ${errorText}`);
}
const result = await response.json();
console.log('PDF URL:', result.documentUrl);
}
generatePdf().catch(console.error);
```
**Convert HTML content and get download URL:**
```js
async function generatePdf() {
const htmlContent = 'Hello!This is a sample PDF.';
const base64Html = Buffer.from(htmlContent).toString('base64');
const response = await fetch('https://api.pdfbolt.com/v1/sync', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'API-KEY': 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
},
body: JSON.stringify({
html: base64Html,
margin: {
top: '30px',
left: '30px'
}
})
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`HTTP ${response.status} - ${errorText}`);
}
const result = await response.json();
console.log('PDF URL:', result.documentUrl);
}
generatePdf().catch(console.error);
```
**Use templates and get download URL:**
```js
async function generatePdf() {
const response = await fetch('https://api.pdfbolt.com/v1/sync', {
method: 'POST',
headers: {
'API-KEY': 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
'Content-Type': 'application/json'
},
body: JSON.stringify({
templateId: 'your-template-id',
templateData: {
client_name: 'John Doe',
invoice_number: 'INV-001',
total_amount: '$299.99',
line_items: [
{ description: 'Web Development', unit_price: '$200.00' },
{ description: 'Design Services', unit_price: '$99.99' }
]
}
})
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`HTTP ${response.status} - ${errorText}`);
}
const result = await response.json();
console.log('PDF URL:', result.documentUrl);
}
generatePdf().catch(console.error);
```
The **Async** endpoint processes requests asynchronously and sends results via webhook.
**➡️ Sources:**
**Convert webpage with webhook notification:**
```js
async function generatePdf() {
const response = await fetch('https://api.pdfbolt.com/v1/async', {
method: 'POST',
headers: {
'API-KEY': 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://example.com',
format: 'A4',
printBackground: true,
webhook: 'https://your-app.com/webhook'
})
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`HTTP ${response.status} - ${errorText}`);
}
const result = await response.json();
console.log('Request ID:', result.requestId);
console.log('PDF will be sent to webhook when ready');
}
generatePdf().catch(console.error);
```
**Convert HTML with webhook notification:**
```js
async function generatePdf() {
const htmlContent = 'Hello!This is a sample PDF.';
const base64Html = Buffer.from(htmlContent).toString('base64');
const response = await fetch('https://api.pdfbolt.com/v1/async', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'API-KEY': 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
},
body: JSON.stringify({
html: base64Html,
margin: {
top: '30px',
left: '30px'
},
webhook: 'https://your-app.com/webhook'
})
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`HTTP ${response.status} - ${errorText}`);
}
const result = await response.json();
console.log('Request ID:', result.requestId);
console.log('PDF will be sent to webhook when ready');
}
generatePdf().catch(console.error);
```
**Use templates with webhook notification:**
```js
async function generatePdf() {
const response = await fetch('https://api.pdfbolt.com/v1/async', {
method: 'POST',
headers: {
'API-KEY': 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
'Content-Type': 'application/json'
},
body: JSON.stringify({
templateId: 'your-template-id',
templateData: {
client_name: 'John Doe',
invoice_number: 'INV-001',
total_amount: '$299.99',
line_items: [
{ description: 'Web Development', unit_price: '$200.00' },
{ description: 'Design Services', unit_price: '$99.99' }
]
},
webhook: 'https://your-app.com/webhook'
})
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`HTTP ${response.status} - ${errorText}`);
}
const result = await response.json();
console.log('Request ID:', result.requestId);
console.log('PDF will be sent to webhook when ready');
}
generatePdf().catch(console.error);
```
### 3. What's next?
Continue your journey with PDFBolt by exploring its powerful features and benefits. Start by checking the available [API Endpoints](/docs/api-endpoints) and dive into the [Conversion Parameters](/docs/parameters) to customize your integration for your unique needs.
---
## Python
# Quick Start for Python
Python offers several libraries for PDF generation, but they can be complex to set up and configure. Our PDF generation API provides a simpler, more flexible way to generate PDFs from HTML, URLs, and dynamic templates. Here's how to start in Python.
### 1. Get Your API Key
* After registering, log in to the **Admin Dashboard** and navigate to the **API Keys** section to retrieve your API key.
* Ensure you keep this key secure, as it is essential for authorizing your requests to the PDFBolt API.
### 2. Make Your First Request
Use these examples to make requests to the PDFBolt API and generate PDFs quickly.
**Choose your preferred endpoint and source combination.**
**➡️ Endpoints:**
The **Direct** endpoint provides immediate PDF generation and returns the raw PDF file in the response.
**➡️ Sources:**
**Convert any webpage into a PDF:**
```python
url = "https://api.pdfbolt.com/v1/direct"
headers = {
"API-KEY": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"Content-Type": "application/json"
}
data_json = '''{
"url": "https://example.com",
"format": "A4",
"printBackground": true
}'''
data = json.loads(data_json)
try:
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
with open('webpage.pdf', 'wb') as f:
f.write(response.content)
print("PDF generated successfully")
except requests.exceptions.HTTPError as e:
print(f"HTTP {response.status_code}")
print(f"Error Message: {response.text}")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
```
**Convert HTML content directly into a PDF:**
```python
html_content = "Hello!This is a sample PDF."
base64_html = base64.b64encode(html_content.encode()).decode()
url = "https://api.pdfbolt.com/v1/direct"
headers = {
"API-KEY": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"Content-Type": "application/json"
}
data_json = f'''{{
"html": "{base64_html}",
"margin": {{
"top": "30px",
"left": "30px"
}}
}}'''
data = json.loads(data_json)
try:
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
with open('document.pdf', 'wb') as f:
f.write(response.content)
print("PDF generated successfully")
except requests.exceptions.HTTPError as e:
print(f"HTTP {response.status_code}")
print(f"Error Message: {response.text}")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
```
**Use reusable templates for dynamic PDF generation:**
```python
url = "https://api.pdfbolt.com/v1/direct"
headers = {
"API-KEY": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"Content-Type": "application/json"
}
data_json = '''{
"templateId": "your-template-id",
"templateData": {
"client_name": "John Doe",
"invoice_number": "INV-001",
"total_amount": "$299.99",
"line_items": [
{"description": "Web Development", "unit_price": "$200.00"},
{"description": "Design Services", "unit_price": "$99.99"}
]
}
}'''
data = json.loads(data_json)
try:
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
with open('invoice.pdf', 'wb') as f:
f.write(response.content)
print("PDF generated successfully")
except requests.exceptions.HTTPError as e:
print(f"HTTP {response.status_code}")
print(f"Error Message: {response.text}")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
```
:::info New to templates?
Create your first template in the app, then use its ID in your API calls.
**[→ Learn more about Templates](/docs/pdf-templates)**
:::
The **Sync** endpoint returns a JSON response with a download URL for the PDF.
**➡️ Sources:**
**Convert webpage and get download URL:**
```python
url = "https://api.pdfbolt.com/v1/sync"
headers = {
"API-KEY": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"Content-Type": "application/json"
}
data_json = '''{
"url": "https://example.com",
"format": "A4",
"printBackground": true
}'''
data = json.loads(data_json)
try:
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
result = response.json()
print(f"PDF URL: {result['documentUrl']}")
except requests.exceptions.HTTPError as e:
print(f"HTTP {response.status_code}")
print(f"Error Message: {response.text}")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
```
**Convert HTML and get download URL:**
```python
html_content = "Hello!This is a sample PDF."
base64_html = base64.b64encode(html_content.encode()).decode()
url = "https://api.pdfbolt.com/v1/sync"
headers = {
"API-KEY": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"Content-Type": "application/json"
}
data_json = f'''{{
"html": "{base64_html}",
"margin": {{
"top": "30px",
"left": "30px"
}}
}}'''
data = json.loads(data_json)
try:
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
result = response.json()
print(f"PDF URL: {result['documentUrl']}")
except requests.exceptions.HTTPError as e:
print(f"HTTP {response.status_code}")
print(f"Error Message: {response.text}")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
```
**Use templates and get download URL:**
```python
url = "https://api.pdfbolt.com/v1/sync"
headers = {
"API-KEY": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"Content-Type": "application/json"
}
data_json = '''{
"templateId": "your-template-id",
"templateData": {
"client_name": "John Doe",
"invoice_number": "INV-001",
"total_amount": "$299.99",
"line_items": [
{"description": "Web Development", "unit_price": "$200.00"},
{"description": "Design Services", "unit_price": "$99.99"}
]
}
}'''
data = json.loads(data_json)
try:
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
result = response.json()
print(f"PDF URL: {result['documentUrl']}")
except requests.exceptions.HTTPError as e:
print(f"HTTP {response.status_code}")
print(f"Error Message: {response.text}")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
```
The **Async** endpoint processes requests asynchronously and sends results via webhook.
**➡️ Sources:**
**Convert webpage with webhook notification:**
```python
url = "https://api.pdfbolt.com/v1/async"
headers = {
"API-KEY": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"Content-Type": "application/json"
}
data_json = '''{
"url": "https://example.com",
"format": "A4",
"printBackground": true,
"webhook": "https://your-app.com/webhook"
}'''
data = json.loads(data_json)
try:
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
result = response.json()
print(f"Request ID: {result['requestId']}")
print("PDF will be sent to webhook when ready")
except requests.exceptions.HTTPError as e:
print(f"HTTP {response.status_code}")
print(f"Error Message: {response.text}")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
```
**Convert HTML with webhook notification:**
```python
html_content = "Hello!This is a sample PDF."
base64_html = base64.b64encode(html_content.encode()).decode()
url = "https://api.pdfbolt.com/v1/async"
headers = {
"API-KEY": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"Content-Type": "application/json"
}
data_json = f'''{{
"html": "{base64_html}",
"margin": {{
"top": "30px",
"left": "30px"
}},
"webhook": "https://your-app.com/webhook"
}}'''
data = json.loads(data_json)
try:
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
result = response.json()
print(f"Request ID: {result['requestId']}")
print("PDF will be sent to webhook when ready")
except requests.exceptions.HTTPError as e:
print(f"HTTP {response.status_code}")
print(f"Error Message: {response.text}")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
```
**Use templates with webhook notification:**
```python
url = "https://api.pdfbolt.com/v1/async"
headers = {
"API-KEY": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"Content-Type": "application/json"
}
data_json = '''{
"templateId": "your-template-id",
"templateData": {
"client_name": "John Doe",
"invoice_number": "INV-001",
"total_amount": "$299.99",
"line_items": [
{"description": "Web Development", "unit_price": "$200.00"},
{"description": "Design Services", "unit_price": "$99.99"}
]
},
"webhook": "https://your-app.com/webhook"
}'''
data = json.loads(data_json)
try:
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
result = response.json()
print(f"Request ID: {result['requestId']}")
print("PDF will be sent to webhook when ready")
except requests.exceptions.HTTPError as e:
print(f"HTTP {response.status_code}")
print(f"Error Message: {response.text}")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
```
### 3. What's next?
Continue your journey with PDFBolt by exploring its powerful features and benefits. Start by checking the available [API Endpoints](/docs/api-endpoints) and dive into the [Conversion Parameters](/docs/parameters) to customize your integration for your unique needs.
---
## Java
# Quick Start for Java
Java supports wkhtmltopdf integration, but Puppeteer requires additional workarounds due to its lack of native support. PDFBolt's PDF generation API offers a faster and more reliable approach to generating PDFs from HTML, URLs, and dynamic templates. Follow these steps to get started with Java.
### 1. Get Your API Key
* Your API Key is available in the **Admin Dashboard** under the **API Keys** section after registration.
* Ensure you keep this key secure, as it is required for authorization requests to the PDFBolt API.
### 2. Make Your First Request
Use the following examples to quickly make requests to the PDFBolt API and generate your PDF documents.
**Choose your preferred endpoint and source combination.**
**➡️ Endpoints:**
The **Direct** endpoint provides immediate PDF generation and returns the raw PDF file in the response.
**➡️ Sources:**
**Convert any webpage into a PDF:**
```java
public class PDFBoltIntegrationUrl {
public static void main(String[] args) throws Exception {
String jsonBody = """
{
"url": "https://example.com",
"format": "A4",
"printBackground": true
}
""";
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.pdfbolt.com/v1/direct"))
.header("API-KEY", "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
if (response.statusCode() == 200) {
Files.write(Paths.get("webpage.pdf"), response.body());
System.out.println("PDF generated successfully");
} else {
System.err.println("HTTP " + response.statusCode());
System.err.println("Error Message: " + new String(response.body()));
}
}
}
```
**Convert HTML content directly into a PDF:**
```java
public class PDFBoltIntegrationHtml {
public static void main(String[] args) throws Exception {
String htmlContent = "Hello!This is a sample PDF.";
String base64Html = Base64.getEncoder().encodeToString(htmlContent.getBytes());
String jsonBody = """
{
"html": "%s",
"margin": {
"top": "30px",
"left": "30px"
}
}
""".formatted(base64Html);
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.pdfbolt.com/v1/direct"))
.header("API-KEY", "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
if (response.statusCode() == 200) {
Files.write(Paths.get("document.pdf"), response.body());
System.out.println("PDF generated successfully");
} else {
System.err.println("HTTP " + response.statusCode());
System.err.println("Error Message: " + new String(response.body()));
}
}
}
```
**Use reusable templates for dynamic PDF generation:**
```java
public class PDFBoltIntegrationTemplate {
public static void main(String[] args) throws Exception {
String jsonBody = """
{
"templateId": "your-template-id",
"templateData": {
"client_name": "John Doe",
"invoice_number": "INV-001",
"total_amount": "$299.99",
"line_items": [
{
"description": "Web Development",
"unit_price": "$200.00"
},
{
"description": "Design Services",
"unit_price": "$99.99"
}
]
}
}
""";
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.pdfbolt.com/v1/direct"))
.header("API-KEY", "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
if (response.statusCode() == 200) {
Files.write(Paths.get("invoice.pdf"), response.body());
System.out.println("PDF generated successfully");
} else {
System.err.println("HTTP " + response.statusCode());
System.err.println("Error Message: " + new String(response.body()));
}
}
}
```
:::info New to templates?
Create your first template in the app, then use its ID in your API calls.
**[→ Learn more about Templates](/docs/pdf-templates)**
:::
The **Sync** endpoint returns a JSON response with a download URL for the PDF.
**➡️ Sources:**
**Convert webpage and get download URL:**
```java
public class PDFBoltIntegrationUrl {
public static void main(String[] args) throws Exception {
String jsonBody = """
{
"url": "https://example.com",
"format": "A4",
"printBackground": true
}
""";
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.pdfbolt.com/v1/sync"))
.header("API-KEY", "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
String responseBody = response.body();
String documentUrl = responseBody.split("\"documentUrl\":\"")[1].split("\"")[0];
System.out.println("PDF URL: " + documentUrl);
} else {
System.err.println("HTTP " + response.statusCode());
System.err.println("Error Message: " + response.body());
}
}
}
```
**Convert HTML and get download URL:**
```java
public class PDFBoltIntegrationHtml {
public static void main(String[] args) throws Exception {
String htmlContent = "Hello!This is a sample PDF.";
String base64Html = Base64.getEncoder().encodeToString(htmlContent.getBytes());
String jsonBody = """
{
"html": "%s",
"margin": {
"top": "30px",
"left": "30px"
}
}
""".formatted(base64Html);
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.pdfbolt.com/v1/sync"))
.header("API-KEY", "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
String responseBody = response.body();
String documentUrl = responseBody.split("\"documentUrl\":\"")[1].split("\"")[0];
System.out.println("PDF URL: " + documentUrl);
} else {
System.err.println("HTTP " + response.statusCode());
System.err.println("Error Message: " + response.body());
}
}
}
```
**Use templates and get download URL:**
```java
public class PDFBoltIntegrationTemplate {
public static void main(String[] args) throws Exception {
String jsonBody = """
{
"templateId": "your-template-id",
"templateData": {
"client_name": "John Doe",
"invoice_number": "INV-001",
"total_amount": "$299.99",
"line_items": [
{
"description": "Web Development",
"unit_price": "$200.00"
},
{
"description": "Design Services",
"unit_price": "$99.99"
}
]
}
}
""";
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.pdfbolt.com/v1/sync"))
.header("API-KEY", "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
String responseBody = response.body();
String documentUrl = responseBody.split("\"documentUrl\":\"")[1].split("\"")[0];
System.out.println("PDF URL: " + documentUrl);
} else {
System.err.println("HTTP " + response.statusCode());
System.err.println("Error Message: " + response.body());
}
}
}
```
The **Async** endpoint processes requests asynchronously and sends results via webhook.
**➡️ Sources:**
**Convert webpage with webhook notification:**
```java
public class PDFBoltIntegrationUrl {
public static void main(String[] args) throws Exception {
String jsonBody = """
{
"url": "https://example.com",
"format": "A4",
"printBackground": true,
"webhook": "https://your-app.com/webhook"
}
""";
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.pdfbolt.com/v1/async"))
.header("API-KEY", "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
String responseBody = response.body();
String requestId = responseBody.split("\"requestId\":\"")[1].split("\"")[0];
System.out.println("Request ID: " + requestId);
System.out.println("PDF will be sent to webhook when ready");
} else {
System.err.println("HTTP " + response.statusCode());
System.err.println("Error Message: " + response.body());
}
}
}
```
**Convert HTML with webhook notification:**
```java
public class PDFBoltIntegrationHtml {
public static void main(String[] args) throws Exception {
String htmlContent = "Hello!This is a sample PDF.";
String base64Html = Base64.getEncoder().encodeToString(htmlContent.getBytes());
String jsonBody = """
{
"html": "%s",
"margin": {
"top": "30px",
"left": "30px"
},
"webhook": "https://your-app.com/webhook"
}
""".formatted(base64Html);
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.pdfbolt.com/v1/async"))
.header("API-KEY", "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
String responseBody = response.body();
String requestId = responseBody.split("\"requestId\":\"")[1].split("\"")[0];
System.out.println("Request ID: " + requestId);
System.out.println("PDF will be sent to webhook when ready");
} else {
System.err.println("HTTP " + response.statusCode());
System.err.println("Error Message: " + response.body());
}
}
}
```
**Use templates with webhook notification:**
```java
public class PDFBoltIntegrationTemplate {
public static void main(String[] args) throws Exception {
String jsonBody = """
{
"templateId": "your-template-id",
"templateData": {
"client_name": "John Doe",
"invoice_number": "INV-001",
"total_amount": "$299.99",
"line_items": [
{
"description": "Web Development",
"unit_price": "$200.00"
},
{
"description": "Design Services",
"unit_price": "$99.99"
}
]
},
"webhook": "https://your-app.com/webhook"
}
""";
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.pdfbolt.com/v1/async"))
.header("API-KEY", "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
String responseBody = response.body();
String requestId = responseBody.split("\"requestId\":\"")[1].split("\"")[0];
System.out.println("Request ID: " + requestId);
System.out.println("PDF will be sent to webhook when ready");
} else {
System.err.println("HTTP " + response.statusCode());
System.err.println("Error Message: " + response.body());
}
}
}
```
### 3. What's next?
Unlock the full potential of PDFBolt by exploring its powerful features and customization options. Start with the [API Endpoints](/docs/api-endpoints) and delve into the [Conversion Parameters](/docs/parameters) to tailor your integration to your needs.
---
## PHP
# Quick Start for PHP
While wkhtmltopdf is commonly used in PHP and Puppeteer requires workarounds due to its Node.js nature, PDFBolt's PDF generation API delivers a streamlined solution for generating PDFs from HTML, URLs, and dynamic templates without needing binary installations or complex setups.
### 1. Get Your API Key
* After signing up, locate your API Key in the **Admin Dashboard** under the **API Keys** section.
* This key is essential for authorizing your requests to the PDFBolt API. Remember to keep it secure.
### 2. Make Your First Request
Try these examples to start making requests to the PDFBolt API and create your PDFs.
Choose your preferred endpoint and source combination:
**➡️ Endpoints:**
The **Direct** endpoint provides immediate PDF generation and returns the raw PDF file in the response.
**➡️ Sources:**
**Convert any webpage into a PDF:**
```php
post('https://api.pdfbolt.com/v1/direct', [
'headers' => $phpHeaders,
'json' => $phpBody
]);
file_put_contents('webpage.pdf', $response->getBody());
echo "PDF generated successfully\n";
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
?>
```
**Convert HTML content directly into a PDF:**
```php
Hello!This is a sample PDF.