import requests
response = requests.post(
"https://api.headlesspdf.com/v1/generate-pdf",
headers={"X-API-Key": "YOUR_KEY"},
json={
"url": "https://example.com/invoice/1024",
"format": "A4"
}
)
# Save the PDF
with open("invoice.pdf", "wb") as f:
f.write(response.content)
const response = await fetch("https://api.headlesspdf.com/v1/generate-pdf", {
method: "POST",
headers: {
"X-API-Key": "YOUR_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
url: "https://example.com/invoice/1024",
format: "A4"
})
});
const buffer = await response.arrayBuffer();
// Save the PDF (Node.js)
require("fs").writeFileSync("invoice.pdf", Buffer.from(buffer));
curl https://api.headlesspdf.com/v1/generate-pdf \
-H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/invoice/1024",
"format": "A4"
}' \
--output invoice.pdf
require 'httparty'
response = HTTParty.post(
"https://api.headlesspdf.com/v1/generate-pdf",
headers: {
"X-API-Key" => "YOUR_KEY",
"Content-Type" => "application/json"
},
body: {
url: "https://example.com/invoice/1024",
format: "A4"
}.to_json
)
File.write("invoice.pdf", response.body, mode: "wb")