Scale PDF Generation from HTML using Gotenberg

What is Gotenberg?
Gotenberg is a powerful, open-source web API dedicated to converting various document formats into PDFs. Written in Go and currently at version 8, it excels at swiftly transforming HTML, URLs, and Markdown files into professional PDFs. Ideal for developers seeking scalable document conversion solutions, Gotenberg's Docker-based deployment simplifies the setup and maintenance processes, making it perfect for SaaS platforms.
You can check out their well-written and complete documentation here.
Setting Up Your Gotenberg Instance
Since Gotenberg is fully containerized, you have multiple deployment methods at your disposal—from local Docker setups to managed Kubernetes clusters and cloud-based serverless solutions. If you're unfamiliar with deploying containerized applications, this guide will walk you through each approach clearly and step by step.
Deploying Gotenberg using Docker Compose
Deploying Gotenberg with Docker Compose is straightforward. Ensure Docker is installed and running:
Run docker-compose up -d
to initiate your instance rapidly.
Deploying Gotenberg using Kubernetes
For resilience and scalability, Kubernetes deployment is ideal. Use this deployment YAML:
Deploy with kubectl apply -f gotenberg.yaml
.
Deploying Gotenberg using Google Cloud Run
For cost-effective serverless deployment, Google Cloud Run is a compelling choice. Utilize the specialized Docker image:
- gotenberg/gotenberg:8-cloudrun
- Alternatively, use the historical Docker image: thecodingmachine/gotenberg:8-cloudrun
Use the Google Cloud CLI:
Deploying Gotenberg using AWS ECS
AWS ECS offers scalable container orchestration for Gotenberg:
- Create a task definition in ECS with the Docker image gotenberg/gotenberg:8
.
- Configure resources (minimum 1Gi memory recommended).
- Set up an ECS service for automated management and scaling.
- Use an Application Load Balancer for incoming requests.
Generating PDF with Gotenberg
Generating PDF using an URL
Generate PDFs directly from URLs via simple HTTP requests:
Generating PDF from HTML
Convert HTML files into PDFs seamlessly:
Generating PDF from Markdown
Quickly convert Markdown files:
Advanced PDF Configurations
Print options
Customize your PDF output extensively:
singlePage
: falsepaperWidth
: 8.5paperHeight
: 11marginTop
: 0.39marginBottom
: 0.39marginLeft
: 0.39marginRight
: 0.39preferCssPageSize
: falsegenerateDocumentOutline
: falseprintBackground
: falseomitBackground
: falselandscape
: falsescale
: 1.0nativePageRanges
: All pages
Example request:
Generating PDF Header and Footer
Customize headers and footers with HTML strings, leveraging classes like pageNumber
, totalPages
, title
, and date
:
Other PDF Functions
Gotenberg leverages LibreOffice to handle diverse PDF tasks, including merging, splitting, compression, and converting to archival PDF/A formats.
Merge example:
Alternative: Generate PDFs Using pdforge

pdforge is a third-party pdf generation API. You can create beautiful reports with flexible layouts and complex components with an easy-to-use opinionated no-code builder. Let the AI do the heavy lifting by generating your templates, creating custom components or even filling all the variables for you.
You can handle high-volume PDF generation from a single backend call.
Here’s an example of how to generate pdf with pdforge via an API call:
You can create your account, experience our no-code builder and create your first layout template without any upfront payment clicking here.
Conclusion
Gotenberg offers an efficient, containerized approach to generating PDFs at scale, making it highly suitable for applications with predictable, consistent document formats. Its versatility in deployment and ease of integration into existing infrastructures make it a robust choice for SaaS developers.
However, for teams seeking simplicity, dynamic templates, or those wanting to offload infrastructure maintenance, solutions like pdforge present compelling alternatives. By streamlining the complexities of dynamic document creation and handling scalable PDF generation effortlessly, pdforge helps SaaS companies prioritize innovation and productivity over operational concerns.