Turn HTML into PDFs
Send HTML, get a PDF download link. Invoices, reports, receipts, contracts. If you can build it in HTML, we can turn it into a PDF.
Send HTML, get a PDF
Pass an HTML string in the request body. We render it and return a download link.
const response = await fetch('https://api.pdfshot.com/convert', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
html: '<h1>Invoice #1234</h1><p>Amount: $99.00</p>'
})
});
const { url } = await response.json();
// url = "https://cdn.pdfshot.com/abc123.pdf"
import requests
response = requests.post(
'https://api.pdfshot.com/convert',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'html': '<h1>Invoice #1234</h1><p>Amount: $99.00</p>'
}
)
url = response.json()['url']
# url = "https://cdn.pdfshot.com/abc123.pdf"
payload := map[string]string{
"html": "<h1>Invoice #1234</h1><p>Amount: $99.00</p>",
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST",
"https://api.pdfshot.com/convert",
bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
// Response: { "url": "https://cdn.pdfshot.com/abc123.pdf" }
require 'net/http'
require 'json'
uri = URI('https://api.pdfshot.com/convert')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = { html: '<h1>Invoice #1234</h1><p>Amount: $99.00</p>' }.to_json
response = http.request(request)
url = JSON.parse(response.body)['url']
# url = "https://cdn.pdfshot.com/abc123.pdf"
$ch = curl_init('https://api.pdfshot.com/convert');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => json_encode([
'html' => '<h1>Invoice #1234</h1><p>Amount: $99.00</p>'
])
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
$url = $data['url'];
// $url = "https://cdn.pdfshot.com/abc123.pdf"
curl -X POST https://api.pdfshot.com/convert \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Invoice #1234</h1><p>Amount: $99.00</p>"}'
# Response: {"url": "https://cdn.pdfshot.com/abc123.pdf"}
Or just send a URL
Point us at any public webpage. We'll fetch it, render it, and give you the PDF.
const response = await fetch('https://api.pdfshot.com/convert', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://pdfshot.com/demo/invoice'
})
});
const { url } = await response.json();
// url = "https://cdn.pdfshot.com/def456.pdf"
import requests
response = requests.post(
'https://api.pdfshot.com/convert',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'url': 'https://pdfshot.com/demo/invoice'
}
)
url = response.json()['url']
# url = "https://cdn.pdfshot.com/def456.pdf"
payload := map[string]string{
"url": "https://pdfshot.com/demo/invoice",
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST",
"https://api.pdfshot.com/convert",
bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
// Response: { "url": "https://cdn.pdfshot.com/def456.pdf" }
require 'net/http'
require 'json'
uri = URI('https://api.pdfshot.com/convert')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = { url: 'https://pdfshot.com/demo/invoice' }.to_json
response = http.request(request)
url = JSON.parse(response.body)['url']
# url = "https://cdn.pdfshot.com/def456.pdf"
$ch = curl_init('https://api.pdfshot.com/convert');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://pdfshot.com/demo/invoice'
])
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
$url = $data['url'];
// $url = "https://cdn.pdfshot.com/def456.pdf"
curl -X POST https://api.pdfshot.com/convert \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://pdfshot.com/demo/invoice"}'
# Response: {"url": "https://cdn.pdfshot.com/def456.pdf"}
Why PDFShot
A PDF API that does one thing well.
- Accurate RenderingCSS Grid, Flexbox, web fonts, and print styles all render correctly.
- Fast ResponseMost single-page documents convert in under a second. No waiting around.
- Simple APIPOST your HTML or a URL. Get back a JSON response with a link to your PDF.
- Stored TemplatesSave your HTML templates and render them with variables. Good for invoices or any doc you generate repeatedly.
- Auto-Expiring LinksPDF links expire after 1 hour and the files are deleted. Your documents don't stick around.
- Pay As You Go5 free render minutes every month. After that, $0.20 per minute. No subscriptions, no minimums.