API Endpoint Access URL
https://api.pixlab.io/pdfgen
Get Your API Key & Try PDFGEN Now ↗Description
The PDF Generation API lets developers create invoices, reports, receipts, certificates, and other branded documents directly from code. Send Markdown, plain text, or HTML with images, links, and structured content, and PDFGEN will render the final PDF without requiring a separate PDF library in your stack. For bulk workflows, templates, and higher-level automation patterns, see the Rich PDF Generation page.
HTTP Methods
POST
HTTP Parameters
| Fields | Type | Description |
|---|---|---|
input |
String | Blob | Raw document content to render into the generated PDF. Supported formats in this release are markdown, html, and plaintext. |
format |
String | Format | Format of the submitted input content. Supported values in this release are markdown, html, and plaintext. |
key |
String | Your PixLab API Key ↗. You can also embed your key in the WWW-Authenticate: HTTP header and omit this parameter. |
Optional
| Fields | Type | Description |
|---|---|---|
blob |
Boolean | By default, the API returns a JSON object with the generated PDF link. If set to true, the raw PDF binary is returned instead. |
POST Request Body
Use this section when calling the endpoint with POST.
Allowed Content-Types:
multipart/form-dataapplication/json
HTTP Response
The endpoint returns application/json if the optional blob parameter is not set.
This endpoint returns a JSON object after each call unless the optional blob parameter is set to true. In the default mode, the response includes a link to the generated PDF stored in the AWS S3 bucket configured through the PixLab Console ↗. If blob=true, the generated PDF is returned directly. The JSON response includes the following fields:
| Fields | Type | Description |
|---|---|---|
status |
Integer | Status code 200 indicates success. Any other code indicates failure. |
link |
URL | Link to the generated PDF document stored directly on your AWS S3 bucket, which you registered through the PixLab Console ↗. |
id |
String | Unique media identifier. |
error |
String | Error message when status ≠ 200. |
Code Samples
# Programmatically Generate PDF document from markdown or HTML input
import requests
import json
# Replace with your actual PixLab API key
api_key = "YOUR_PIXLAB_API_KEY" # Get yours from https://console.pixlab.io/
# Markdown formatted invoice
markdown_text = """
# Invoice
## To:
Acme Corp.
123 Main St.
Anytown, USA
## From:
Your Company
456 Oak Ave.
Anytown, USA
## Date:
2024-01-26
## Invoice Number:
INV-2024-001
## Items:
| Item | Quantity | Price |
|---------------|----------|----------|
| Widget | 2 | $10.00 |
| Gadget | 1 | $25.00 |
| Service | 1 | $50.00 |
## Subtotal:
$85.00
## Tax:
$5.00
## Total:
$90.00
## Notes:
Thank you for your business!
"""
# API endpoint to programmatically generate PDFs from markdown or HTML input
api_endpoint = "https://api.pixlab.io/pdfgen"
# Request parameters
payload = {
"key": api_key,
"input": markdown_text,
"format": "markdown"
}
# Convert payload to JSON
headers = {'Content-Type': 'application/json'}
# Make the POST request
try:
response = requests.post(api_endpoint, headers=headers, data=json.dumps(payload))
# Check for successful response
if response.status_code == 200:
data = response.json()
if data.get("status") == 200:
pdf_link = data.get("link")
print(f"PDF generated successfully. Link: {pdf_link}")
else:
print(f"Error generating PDF: {data.get('error')}")
else:
print(f"Request failed with status code: {response.status_code}")
print(response.text) # Print the response content for debugging
except requests.exceptions.RequestException as e:
print(f"An error occurred: {e}")
// Programmatically Generate PDF document from markdown or HTML input
// Replace with your actual PixLab API key
const apiKey = "YOUR_PIXLAB_API_KEY"; // Get yours from https://console.pixlab.io/
// Markdown formatted invoice
const markdownText = `
# Invoice
## To:
Acme Corp.
123 Main St.
Anytown, USA
## From:
Your Company
456 Oak Ave.
Anytown, USA
## Date:
2024-01-26
## Invoice Number:
INV-2024-001
## Items:
| Item | Quantity | Price |
|---------------|----------|----------|
| Widget | 2 | $10.00 |
| Gadget | 1 | $25.00 |
| Service | 1 | $50.00 |
## Subtotal:
$85.00
## Tax:
$5.00
## Total:
$90.00
## Notes:
Thank you for your business!
`;
// API endpoint to programmatically generate PDFs from markdown or HTML input
const apiEndpoint = "https://api.pixlab.io/pdfgen";
// Request parameters
const payload = {
key: apiKey,
input: markdownText,
format: "markdown"
};
// Make the POST request
fetch(apiEndpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
})
.then(response => {
if (response.status === 200) {
return response.json();
} else {
console.error(`Request failed with status code: ${response.status}`);
return response.text().then(text => { throw new Error(text) }); // Throw error to be caught in catch block
}
})
.then(data => {
if (data.status === 200) {
const pdfLink = data.link;
console.log(`PDF generated successfully. Link: ${pdfLink}`);
} else {
console.error(`Error generating PDF: ${data.error}`);
}
})
.catch(error => {
console.error(`An error occurred: ${error}`);
});
<?php
# Programmatically Generate PDF document from markdown or HTML input
# Replace with your actual PixLab API key
$api_key = "YOUR_PIXLAB_API_KEY"; // Get yours from https://console.pixlab.io/
# Markdown formatted invoice
$markdown_text = <<<EOD
# Invoice
## To:
Acme Corp.
123 Main St.
Anytown, USA
## From:
Your Company
456 Oak Ave.
Anytown, USA
## Date:
2024-01-26
## Invoice Number:
INV-2024-001
## Items:
| Item | Quantity | Price |
|---------------|----------|----------|
| Widget | 2 | $10.00 |
| Gadget | 1 | $25.00 |
| Service | 1 | $50.00 |
## Subtotal:
$85.00
## Tax:
$5.00
## Total:
$90.00
## Notes:
Thank you for your business!
EOD;
# API endpoint to programmatically generate PDFs from markdown or HTML input
$api_endpoint = "https://api.pixlab.io/pdfgen";
# Request parameters
$payload = array(
"key" =< $api_key,
"input" =< $markdown_text,
"format" =< "markdown"
);
# Initialize cURL
$ch = curl_init($api_endpoint);
# Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
# Execute the cURL request
$response = curl_exec($ch);
# Check for errors
if (curl_errno($ch)) {
echo "Error: " . curl_error($ch);
} else {
# Get the HTTP status code
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($http_status == 200) {
$data = json_decode($response, true);
if ($data && $data["status"] == 200) {
$pdf_link = $data["link"];
echo "PDF generated successfully. Link: " . $pdf_link . "\n";
} else {
echo "Error generating PDF: " . ($data ? $data["error"] : "Unknown error");
}
} else {
echo "Request failed with status code: " . $http_status . "\n";
echo $response; // Print the response content for debugging
}
}
# Close cURL resource
curl_close($ch);
Similar API Endpoints
convert, tagimg, header, encrypt, llm-parse, copy, pdftoimg, llm-tools, query, bg-remove