Getting Started
The PDFSamurai Docker Server is a self-hosted PDF generation server. Deploy it on any infrastructure and generate PDFs via HTTP from any programming language. It uses the @pdfsamurai/pdfsamurai-js library internally and handles worker threads, request queuing, and concurrency out of the box.
All processing happens locally — your dynamic data never leaves your network.
Start the server
docker pull pdfsamurai/server
docker run -p 3000:3000 pdfsamurai/server
The server is now running on http://localhost:3000.
Generate your first PDF
Send a POST request with your template ID, API key, developer key, and dynamic data:
curl -X POST http://localhost:3000/generate \
-H "Content-Type: application/json" \
-d '{
"templateId": "your-template-id",
"apiKey": "your-api-key",
"developerKey": "your-developer-key",
"dynamicData": {"customerName": "John Doe"}
}' \
-o invoice.pdf
You need both an API key and a developer key from your Dashboard. See Integration — Developer keys for how to create one.
The server returns the PDF as binary data (application/pdf).
Examples
Python
import requests
response = requests.post("http://localhost:3000/generate", json={
"templateId": "your-template-id",
"apiKey": "your-api-key",
"developerKey": "your-developer-key",
"dynamicData": {"customerName": "John Doe", "amount": "150"}
})
with open("invoice.pdf", "wb") as f:
f.write(response.content)
Go
body := `{
"templateId": "your-template-id",
"apiKey": "your-api-key",
"developerKey": "your-developer-key",
"dynamicData": {"customerName": "John Doe"}
}`
resp, err := http.Post("http://localhost:3000/generate", "application/json", strings.NewReader(body))
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
pdf, _ := io.ReadAll(resp.Body)
os.WriteFile("invoice.pdf", pdf, 0644)
Node.js
const response = await fetch("http://localhost:3000/generate", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
templateId: "your-template-id",
apiKey: "your-api-key",
developerKey: "your-developer-key",
dynamicData: { customerName: "John Doe" },
}),
});
const pdf = Buffer.from(await response.arrayBuffer());
fs.writeFileSync("invoice.pdf", pdf);
Health check
Verify the server is running and check worker pool status:
curl http://localhost:3000/health
Next steps
- API Reference — all endpoints, request and response formats
- Configuration — environment variables, worker scaling, and resource limits