Generate a PDF from HTML content.
{
"contents": string, // Required: HTML content to render as PDF
"width": number, // Optional: Width of the PDF (default: 172)
"height": number, // Optional: Height of the PDF (default: 240)
"unit": string, // Optional: Unit for width and height (default: "mm", options: "mm", "cm", "in", "px")
"out_of_all": boolean // Optional: Output all pages instead of first page only (default: false)
}fetch('/api/render', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
contents: '<html><body><h1>Hello World</h1></body></html>',
width: 210,
height: 297,
unit: 'mm'
}),
})
.then(response => response.blob())
.then(blob => {
// Handle the PDF blob
});Generate a PDF from a predefined EJS template with provided data.
Requires Bearer token authentication via Authorization header.
{
"papersize": {
"width": number, // Width in mm (e.g., 128.1)
"height": number // Height in mm (e.g., 256.1)
},
"book": {
"title": string, // Book title
"editions": [ // Optional: Edition information
{
"edition_number": string, // e.g., "初版" or ""
"printing_number": string, // e.g., "第1刷" (default: "第1刷")
"release": {
"year": number, // e.g., 2025
"month": number, // 1-12
"day": number // 1-31
}
}
],
"authors": [ // Optional: Author information
{
"role": string, // e.g., "著者"
"name": string // e.g., "山田太郎"
}
],
"isbn": string // Optional: e.g., "978-4-1111-1111"
},
"service_name": string, // Optional: Publication service name (default: "Puboo")
"is_paper_publish": boolean // Optional: Whether it's a paper publication (default: true)
}curl -X POST https://colophon-server.degg.uk/api/colophon \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-H "Content-Type: application/json" \
-d '{
"papersize": {
"width": 128,
"height": 182
},
"book": {
"title": "サンプル書籍",
"editions": [
{
"edition_number": "初版",
"printing_number": "第1刷",
"release": {
"year": 2025,
"month": 1,
"day": 15
}
}
],
"authors": [
{
"role": "著者",
"name": "山田太郎"
}
],
"isbn": "978-4-1111-1111"
},
"service_name": "Puboo",
"is_paper_publish": true
}' -o colophon.pdfGenerate an image (PNG or JPEG) from HTML content or URL.
{
"url": string | null, // Optional: URL to render (takes priority over contents)
"contents": string | null, // Optional: HTML content to render
"width": number, // Optional: Width of the image in pixels (default: 1920)
"height": number, // Optional: Height of the image in pixels (default: 1080)
"format": "jpg" | "png" // Optional: Output format (default: "png", jpg quality: 90)
}fetch('/api/image', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: 'https://example.com',
width: 1920,
height: 1080,
format: 'png'
}),
})
.then(response => response.blob())
.then(blob => {
// Handle the image blob
});fetch('/api/image', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
contents: '<html><body><h1>Hello World</h1></body></html>',
width: 800,
height: 600,
format: 'jpg'
}),
})
.then(response => response.blob())
.then(blob => {
// Handle the image blob
});