### Install and Run Gotenberg.dev Dev Server
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/CONTRIBUTING.md
Installs project dependencies and starts the development server. Use `npm start` for local development.
```bash
npm install
npm start # Dev server at http://localhost:3000
```
--------------------------------
### Install and Run Gotenberg Dev Server
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/CLAUDE.md
Install project dependencies and start the development server for local preview. Also includes commands for formatting, building, and clearing the cache.
```bash
npm install
npm start # Dev server at http://localhost:3000
npm run format # Format all files with Prettier
npm run build # Verify the site builds without errors
npm run serve # Preview the production build locally
npm run clear # Clear the Docusaurus cache
```
--------------------------------
### Install and Start Gotenberg Development
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/README.md
Use these commands to install dependencies and start the development server for Gotenberg. Refer to CONTRIBUTING.md for detailed development guidelines.
```bash
npm install
npm start
```
--------------------------------
### Download From Example
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/webhook-download.mdx
Example of using the downloadFrom form field to fetch a file from a remote URL and include custom HTTP headers.
```bash
curl \
--request POST http://localhost:3000/forms/libreoffice/convert \
--form 'downloadFrom=[
{
"url": "http://url/to/file.docx",
"extraHttpHeaders": {
"X-My-Header": "MyValue"
}
}
]'
-o my.pdf
```
--------------------------------
### Run Gotenberg with Docker
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/getting-started/installation.mdx
Starts a Gotenberg container and exposes the API on port 3000. For a more secure setup, bind to localhost.
```bash
docker run --rm -p "3000:3000" gotenberg/gotenberg:8
```
```bash
docker run --rm -p "127.0.0.1:3000:3000" gotenberg/gotenberg:8
```
--------------------------------
### Start Gotenberg Container and Convert URL to PDF
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/getting-started/introduction.mdx
Use these commands to quickly start a Gotenberg container and then convert a given URL into a PDF file using curl.
```bash
# 1. Start the container.
docker run --rm -p "3000:3000" gotenberg/gotenberg:8
```
```bash
# 2. Convert a URL to PDF.
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://sparksuite.github.io/simple-html-invoice-template/ \
-o invoice.pdf
```
--------------------------------
### Admonition Examples
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/README.md
Examples of how to use admonitions for informational notes, warnings, and dangers in documentation.
```mdx
:::info
Informational note about behavior or context.
:::
```
```mdx
:::warning
Important caveat or potential pitfall.
:::
```
```mdx
:::danger
Breaking behavior, data loss risk, or critical limitation.
:::
```
--------------------------------
### Complete cURL example for embedding files with metadata
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/_shared/_attachments_pdfengines.mdx
This example demonstrates a full cURL command to create a PDF with embedded files and their associated metadata. It includes the request method, endpoint, form data for attachments, and metadata.
```curl
curl \
--request POST http://localhost:3000/forms/create/pdf \
--form embeds=@factur-x.xml \
--form embeds=@logo.png \
--form embedsMetadata='{"factur-x.xml":{"mimeType":"text/xml","relationship":"Alternative"},"logo.png":{"mimeType":"image/png","relationship":"Supplement"}}'
```
--------------------------------
### PDF Conversion with Landscape Orientation
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-libreoffice/convert-to-pdf.mdx
This example demonstrates how to convert a document to PDF while setting the paper orientation to landscape. Ensure the file to be converted is specified in the 'files' form field.
```bash
curl \
--request POST http://localhost:3000/forms/libreoffice/convert \
--form files=@/path/to/document.docx \
--form landscape=true \
-o my.pdf
```
--------------------------------
### Docker CLI Configuration
Source: https://context7.com/gotenberg/gotenberg.dev/llms.txt
Configure Gotenberg via CLI flags when running the container. Example includes setting API timeout, Chromium queue size, and enabling basic authentication.
```bash
docker run --rm -p "3000:3000" gotenberg/gotenberg:8 gotenberg \
--api-timeout=60s \
--chromium-max-queue-size=20 \
--api-enable-basic-auth
```
--------------------------------
### Test Gotenberg API with curl
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/getting-started/installation.mdx
Example of how to convert a URL to a PDF using the Gotenberg API via curl. This command targets the live demo instance.
```bash
curl \
--request POST https://demo.gotenberg.dev/forms/chromium/convert/url \
--form url=https://sparksuite.github.io/simple-html-invoice-template/ \
-o my.pdf
```
--------------------------------
### Screenshot API Request Example
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-chromium/_shared/_rendering_behavior/_rendering_behavior_screenshot.mdx
Use this cURL command to generate a screenshot. Adjust width, height, format, quality, and optimization settings as needed. Ensure the path and method are correctly specified for your Gotenberg instance.
```bash
curl \
--request ${props.method} http://localhost:3000${props.path} \
${props.curlFormData} \
--form width=1280 \
--form height=720 \
--form format=jpeg \
--form quality=85 \
--form optimizeForSpeed=true \
${props.curlOutput}
```
--------------------------------
### Example Header/Footer HTML Structure
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-chromium/_shared/_header_footer.mdx
Use this HTML structure for your header and footer files. Ensure it includes the necessary tags and basic styling for proper rendering. The `-webkit-print-color-adjust: exact;` property is required for background colors to display correctly.
```html
Page of
```
--------------------------------
### GET /debug
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/system/debug.mdx
Returns the runtime configuration, active modules, and dependency versions (Chromium, LibreOffice). Useful for troubleshooting and verifying startup flags. Only available when `API_ENABLE_DEBUG_DATA` is set to `true`.
```APIDOC
## GET /debug
### Description
Returns the runtime configuration, active modules, and dependency versions (Chromium, LibreOffice). Useful for troubleshooting and verifying startup flags. Only available when `API_ENABLE_DEBUG_DATA` is set to `true`.
### Method
GET
### Endpoint
/debug
### Headers
#### Path Parameters
- **Gotenberg-Trace** (string) - Optional - A custom request ID to identify the request in the logs; overrides the default UUID.
### Request Example
```bash
curl --request GET http://localhost:3000/debug
```
### Response
#### Success Response (200)
- **OK** - OK
#### Response Example
```json
{
"example": "See https://demo.gotenberg.dev/debug for details."
}
```
```
--------------------------------
### ApiEndpoint Component Usage
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/README.md
Example of how to use the ApiEndpoint React component to document an API endpoint. It includes method, path, headers, form fields, cURL example, and responses.
```jsx
import ApiEndpoint from "../../components/documentation/ApiEndpoint";
```
--------------------------------
### Metadata (PDF Engines)
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-chromium/_shared/_structure_metadata.mdx
Configure metadata for PDF generation using PDF Engines. This includes options for form fields and cURL examples.
```bash
curl \
--request ${props.method} http://localhost:3000${props.path} \
${props.curlFormData} \
${props.curlOutput}
```
--------------------------------
### Docker Compose Configuration
Source: https://context7.com/gotenberg/gotenberg.dev/llms.txt
Configure Gotenberg using environment variables in a Docker Compose file. Example includes API timeout, Chromium queue size, and basic authentication credentials.
```yaml
services:
gotenberg:
image: gotenberg/gotenberg:8
ports:
- "3000:3000"
environment:
API_TIMEOUT: "60s"
CHROMIUM_MAX_QUEUE_SIZE: "20"
API_ENABLE_BASIC_AUTH: "true"
GOTENBERG_API_BASIC_AUTH_USERNAME: "admin"
GOTENBERG_API_BASIC_AUTH_PASSWORD: "secret"
```
--------------------------------
### Example Stamp Options JSON
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/_shared/_syntax_stamp_pdfengines.mdx
Use this JSON object to configure stamp options like font, size, color, and opacity. Ensure the PDF engine is configured to support these options.
```json
{
"font": "Helvetica",
"points": 24,
"color": "#008000",
"rotation": 0,
"opacity": 0.6
}
```
--------------------------------
### Emulate Media Features with cURL
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-chromium/_shared/_rendering_behavior/_emulated_media_features.mdx
Use the `emulatedMediaFeatures` form field to simulate CSS media features. This example sets both `prefers-color-scheme` to dark and `prefers-reduced-motion` to reduce.
```shell
curl \
--request ${props.method} http://localhost:3000${props.path} \
${props.curlFormData}
--form emulatedMediaFeatures='[{"name": "prefers-color-scheme", "value": "dark"}, {"name": "prefers-reduced-motion", "value": "reduce"}]' \
${props.curlOutput}
```
--------------------------------
### Merge PDF Files with Custom Bookmarks
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/manipulate-pdfs/merge-pdfs.mdx
Merge PDF files while providing custom bookmarks for specific files. This example demonstrates how to map bookmarks to '1_pdf.pdf' and '2_pdf.pdf', with automatic indexing enabled.
```bash
curl \
--request POST http://localhost:3000/forms/pdfengines/merge \
--form files=@/path/to/1_pdf.pdf \
--form files=@/path/to/2_pdf.pdf \
--form autoIndexBookmarks=true \
--form 'bookmarks={\"1_pdf.pdf\":[{\"title\":\"Introduction\",\"page\":1,\"children\":[]}],\"2_pdf.pdf\":[{\"title\":\"Appendix\",\"page\":1,\"children\":[]}]}' \
-o my.pdf
```
--------------------------------
### Docker Compose Setup for Gotenberg with OTEL
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/telemetry.mdx
This Docker Compose file sets up Gotenberg and an OpenTelemetry Collector. Configure environment variables for Gotenberg to export telemetry data to the collector's endpoint.
```yaml
services:
gotenberg:
image: gotenberg/gotenberg:8
ports:
- "3000:3000"
environment:
OTEL_SERVICE_NAME: "gotenberg"
OTEL_TRACES_EXPORTER: "otlp"
OTEL_METRICS_EXPORTER: "otlp"
OTEL_LOGS_EXPORTER: "otlp"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4317"
otel-collector:
image: otel/opentelemetry-collector-contrib
ports:
- "4317:4317"
volumes:
- ./otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml
```
--------------------------------
### Convert PDF to PDF/A or PDF/UA
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/manipulate-pdfs/pdfa-pdfua.mdx
Use this endpoint to convert PDF files to PDF/A (archival) or PDF/UA (accessibility) standards. It requires LibreOffice to be installed and is more resource-intensive. Specify the desired PDF/A standard using the 'pdfa' field or enable PDF/UA compliance with the 'pdfua' field.
```bash
curl \
--request POST http://localhost:3000/forms/pdfengines/convert \
--form files=@/path/to/pdf.pdf \
--form pdfa=PDF/A-1b \
--form pdfua=true \
-o my.pdf
```
--------------------------------
### Configure Gotenberg with CLI Flags using Docker Compose
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/configuration.mdx
Define the command in your docker-compose.yaml to include CLI flags like --my-module-property=foo for Gotenberg. This method is recommended for Docker Compose setups.
```yaml
services:
# Your other services.
gotenberg:
image: gotenberg/gotenberg:8
command:
- "gotenberg"
- "--my-module-property=foo"
```
--------------------------------
### Add Specialized Script Fonts to Docker Image
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/configuration.mdx
Install specific script fonts like Arabic, Bengali, or Hebrew by adding their corresponding packages to your Dockerfile. This example installs Arabic and Thai fonts.
```docker
FROM gotenberg/gotenberg:8
USER root
RUN apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
fonts-hosny-amiri \
fonts-thai-tlwg \
&& rm -rf /var/lib/apt/lists/*
USER gotenberg
```
--------------------------------
### Serve Gotenberg.dev Locally
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/CONTRIBUTING.md
Previews the production build of the site locally. Use `npm run serve` to test the production build.
```bash
npm run serve # Preview the production build locally
```
--------------------------------
### Build Gotenberg.dev Site
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/CONTRIBUTING.md
Builds the production version of the site. Use `npm run build` to verify the site builds without errors.
```bash
npm run build # Verify the site builds without errors
```
--------------------------------
### GET /version
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/system/version.mdx
Retrieves the version of the running Gotenberg instance. This is useful for verifying deployments and ensuring compatibility.
```APIDOC
## GET /version
### Description
Returns the version of the running Gotenberg instance. Useful for verifying deployments.
Custom variants may not print strict semver. For instance, the live demo prints `{semver}-live-demo-snapshot`.
### Method
GET
### Endpoint
/version
### Headers
- **Gotenberg-Trace** (string) - Optional - A custom request ID to identify the request in the logs; overrides the default UUID.
### Request Example
```bash
curl --request GET http://localhost:3000/version
```
### Response
#### Success Response (200)
- **Gotenberg-Trace** (string) - The custom request ID provided in the request header, or a generated UUID if not provided.
- **Body** (string) - The version string of the Gotenberg instance.
#### Response Example
```
Content-Type: text/plain; charset=UTF-8
Gotenberg-Trace: {trace}
Body:
{semver}
```
```
--------------------------------
### GET /prometheus/metrics
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/system/prometheus-metrics.mdx
Exposes internal metrics in Prometheus format. This endpoint is deprecated as of Gotenberg 8.29.0 and users should migrate to OpenTelemetry.
```APIDOC
## GET /prometheus/metrics
### Description
Exposes internal metrics in Prometheus format. This endpoint is deprecated and users should migrate to OpenTelemetry.
### Method
GET
### Endpoint
/prometheus/metrics
### Headers
- **Gotenberg-Trace** (string) - Optional - A custom request ID to identify the request in the logs; overrides the default UUID.
### Request Example
```bash
curl --request GET http://localhost:3000/prometheus/metrics
```
### Response
#### Success Response (200)
- **metrics** (string) - The metrics in Prometheus format.
#### Response Example
```json
# HELP go_goroutines Number of goroutines that currently exist
# TYPE go_goroutines gauge
go_goroutines 7
# HELP go_memstats_alloc_bytes Number of bytes allocated of heap
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 123456
```
```
--------------------------------
### Webhook Error Event JSON
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/webhook-download.mdx
This is an example of an error event JSON payload that Gotenberg sends to the `Gotenberg-Webhook-Events-Url` when a webhook operation fails.
```json
{
"event": "webhook.error",
"correlationId": "unique-request-id",
"timestamp": "2025-01-15T10:30:00.000000000Z",
"error": {
"status": 500,
"message": "conversion failed"
}
}
```
--------------------------------
### Webhook Success Event JSON
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/webhook-download.mdx
This is an example of a success event JSON payload that Gotenberg sends to the `Gotenberg-Webhook-Events-Url` after a successful webhook operation.
```json
{
"event": "webhook.success",
"correlationId": "unique-request-id",
"timestamp": "2025-01-15T10:30:00.000000000Z"
}
```
--------------------------------
### Convert URL to PDF with Basic Options
Source: https://context7.com/gotenberg/gotenberg.dev/llms.txt
Converts a given URL to a PDF document. This is the most basic usage for URL to PDF conversion.
```bash
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://example.com \
-o example.pdf
```
--------------------------------
### Basic HTML to PDF Conversion
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-chromium/convert-html-to-pdf.mdx
Use this endpoint to convert a single HTML file to a PDF document. Ensure the HTML file is named 'index.html' and is sent as a form file.
```bash
curl \
--request POST http://localhost:3000/forms/chromium/convert/html \
--form files=@/path/to/index.html \
-o my.pdf
```
--------------------------------
### Add Microsoft Core Fonts to Docker Image
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/configuration.mdx
Use this Dockerfile snippet to install Microsoft Core Fonts. Ensure you accept the Microsoft EULA before proceeding.
```docker
FROM gotenberg/gotenberg:8
USER root
RUN echo "deb http://deb.debian.org/debian trixie contrib non-free" \
> /etc/apt/sources.list.d/contrib.list \
&& echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" \
| debconf-set-selections \
&& apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
ca-certificates \
wget \
ttf-mscorefonts-installer \
&& rm -rf /var/lib/apt/lists/*
USER gotenberg
```
--------------------------------
### Format Code with Prettier
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/CONTRIBUTING.md
Formats all project files using Prettier. Ensure code adheres to project style guidelines.
```bash
npm run format # Format all files with Prettier
```
--------------------------------
### ApiEndpoint Component Structure
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/src/README.md
Details the ApiEndpoint component used for rendering API documentation, including method badges, parameter lists, cURL examples, and response displays.
```javascript
src/components/documentation/ApiEndpoint.js
```
--------------------------------
### Download From Feature Configuration
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/configuration.mdx
Configure the 'download from' feature, including allowed/denied URLs and retry settings.
```APIDOC
## API Configuration for Download From Feature
### Description
These options control the behavior of the 'download from' feature, allowing you to specify which URLs can be accessed and how retries are handled.
### Method
N/A (Configuration Flags)
### Endpoint
N/A (Configuration Flags)
### Parameters
#### Command-line Flags
- **--api-download-from-allow-list** (string) - Optional - Set the allowed URLs for the download from feature using regular expressions. Accepts multiple patterns via comma-separated values or repeated flags.
- **--api-download-from-deny-list** (string) - Optional - Set the denied URLs for the download from feature using regular expressions. Accepts multiple patterns via comma-separated values or repeated flags. Defaults to internal ranges.
- **--api-download-from-max-retry** (integer) - Optional - Set the maximum number of retries for the download from feature. Defaults to 4.
- **--api-disable-download-from** (boolean) - Optional - Disable the download from feature. Defaults to false.
### Request Example
N/A (Configuration Flags)
### Response
N/A (Configuration Flags)
### Breaking Changes
Since Gotenberg _8.31.0_, `--api-download-from-deny-list` defaults to blocking loopback, RFC1918, link-local, and IPv6 unique-local ranges. It also performs host validation to prevent DNS rebinding. Use `--api-download-from-allow-list` for internal hosts. See [Outbound URL Security](/docs/webhook-download#outbound-url-security).
### Deprecations
N/A
```
--------------------------------
### Project Directory Structure
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/GEMINI.md
Overview of the project's directory layout, including documentation content, source files, components, and configuration.
```tree
docs/
_shared/ Shared partials for PDF engine features
convert-with-chromium/ Chromium endpoint docs + _shared/ partials
convert-with-libreoffice/ LibreOffice endpoint docs
getting-started/ Introduction, installation, clients
manipulate-pdfs/ PDF manipulation endpoint docs
system/ Health, version, debug, metrics endpoint docs
configuration.mdx Module configuration reference
troubleshooting.mdx Common issues and solutions
webhook-download.mdx Webhook and download-from docs
telemetry.mdx Telemetry docs
src/
components/ React components (Homepage, ApiEndpoint, Sponsors)
css/ Global CSS (custom.css)
pages/ Custom pages (index.js)
theme/ Docusaurus theme overrides (DocSidebar)
sidebars.js Navigation structure
docusaurus.config.js Site configuration
```
--------------------------------
### Configure Metrics Export via OTLP
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/telemetry.mdx
Configure Gotenberg to export metrics using OTLP. This setup sends metrics to an OpenTelemetry Collector which then forwards them to a Prometheus-compatible backend.
```yaml
services:
gotenberg:
image: gotenberg/gotenberg:8
environment:
OTEL_METRICS_EXPORTER: "otlp"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4317"
otel-collector:
image: otel/opentelemetry-collector-contrib
volumes:
- ./otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml
```
```yaml
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
exporters:
prometheusremotewrite:
endpoint: "http://prometheus:9090/api/v1/write"
service:
pipelines:
metrics:
receivers: [otlp]
exporters: [prometheusremotewrite]
```
--------------------------------
### Print Media Configuration
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-chromium/_shared/_rendering_behavior/_rendering_behavior_pdf.mdx
Configure print media emulation and background inclusion for PDF generation.
```APIDOC
## POST /convert/pdf
### Description
This endpoint allows for PDF conversion with specific print media configurations.
### Method
POST
### Endpoint
/convert/pdf
### Parameters
#### Query Parameters
- **emulatedMediaType** (enum) - Optional - Media type to emulate ('screen' or 'print'). Defaults to 'print'.
- **printBackground** (boolean) - Optional - Enable to include background colors and images. Defaults to false.
- **preferCssPageSize** (boolean) - Optional - If true, use the CSS page size defined by `@page` rules. Defaults to false.
### Request Example
```json
{
"content": "Hello World
"
}
```
### Response
#### Success Response (200)
- **pdf** (file) - The generated PDF file.
#### Response Example
(Binary file content for PDF)
```
--------------------------------
### Static Asset Path with useBaseUrl
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/src/README.md
Shows how to use the `useBaseUrl` hook to correctly reference static asset paths in Docusaurus.
```javascript
import useBaseUrl from '@docusaurus/useBaseUrl';
// ...
```
--------------------------------
### LibreOffice Conversion API Endpoint
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-libreoffice/convert-to-pdf.mdx
Use this endpoint to convert documents using LibreOffice. Configure image compression and resolution for the output PDF. Ensure the input document is provided as a file.
```bash
curl \
--request POST http://localhost:3000/forms/libreoffice/convert \
--form files=@/path/to/document.docx \
--form losslessImageCompression=false \
--form quality=50 \
--form reduceImageResolution=true \
--form maxImageResolution=75 \
-o my.pdf
```
--------------------------------
### Kubernetes Deployment Configuration
Source: https://context7.com/gotenberg/gotenberg.dev/llms.txt
Configure Gotenberg in a Kubernetes deployment YAML, specifying resource requests, security context, and image. Example includes read-only root filesystem and privilege escalation settings.
```yaml
spec:
containers:
- name: gotenberg
image: gotenberg/gotenberg:8
ports:
- containerPort: 3000
resources:
requests:
memory: "512Mi"
cpu: "200m"
securityContext:
readOnlyRootFilesystem: false
allowPrivilegeEscalation: false
runAsUser: 1001
```
--------------------------------
### Configure Page Layout with API
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-chromium/_shared/_rendering_behavior/_rendering_behavior_pdf.mdx
Use these form fields to control paper size, margins, orientation, and scaling when converting HTML to PDF. Ensure units are specified (e.g., 'in', 'pt', 'cm').
```bash
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://example.com \
--form paperWidth=8.27 \
--form paperHeight=11.7 \
--form marginTop=1 \
--form marginBottom=1 \
--form marginLeft=1 \
--form marginRight=1 \
--form landscape=true \
--form scale=2.0 \
--output output.pdf
```
--------------------------------
### Convert URL to PDF using cURL
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-chromium/convert-url-to-pdf.mdx
Use this cURL command to convert a given URL to a PDF file. Ensure Gotenberg is running and accessible.
```bash
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://my.url \
-o my.pdf
```
--------------------------------
### Emulate Screen Media Type with Curl
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-chromium/_shared/_rendering_behavior/_rendering_behavior_pdf.mdx
Use this command to emulate the 'screen' media type when generating a PDF. This can help match the browser's viewport appearance.
```bash
curl \
--request POST http://localhost:3000/forms/create-pdf \
--form emulatedMediaType=screen \
--output output.pdf
```
--------------------------------
### HTML Template for Markdown Conversion
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-chromium/convert-markdown-to-pdf.mdx
Include this Go template action in your `index.html` file to specify where the converted Markdown content should be injected.
```html
My PDF
{{ toHTML "file.md" }}
```
--------------------------------
### Encrypt PDF Documents with Gotenberg API
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/manipulate-pdfs/merge-pdfs.mdx
The EncryptionPDFEngines component is used for encrypting PDF documents. It allows for setting encryption options and provides a cURL example for the merge endpoint, supporting form fields.
```javascript
```
--------------------------------
### Convert PDF to PDF/A and PDF/UA with Gotenberg API
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/manipulate-pdfs/merge-pdfs.mdx
Use the PDFAPDFUAPDFEngines component for converting PDFs to PDF/A and PDF/UA standards. This component supports form fields and provides a cURL example for the merge endpoint.
```javascript
```
--------------------------------
### Basic PDF Conversion
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-libreoffice/convert-to-pdf.mdx
Use this endpoint to convert one or more files to PDF. The 'files' form field accepts at least one file. The output filename can be specified using the 'Gotenberg-Output-Filename' header.
```bash
curl \
--request POST http://localhost:3000/forms/libreoffice/convert \
--form files=@/path/to/docx \
-o my.pdf
```
--------------------------------
### Define Native Page Ranges for Chromium Conversion
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-chromium/_shared/_split_page_ranges.mdx
Use the `nativePageRanges` form field to specify which pages to print during Chromium conversion. This is faster as unused pages are not rendered. Example: '1-5, 8, 11-13'.
```bash
curl \
--request POST http://localhost:3000/forms/convert/unstructured \
--form nativePageRanges=1-5 \
-o my.pdf
```
--------------------------------
### Convert HTML with Assets to PDF
Source: https://context7.com/gotenberg/gotenberg.dev/llms.txt
Converts an HTML file along with its associated assets (CSS, images) to PDF. Reference assets using relative paths within the HTML.
```bash
curl \
--request POST http://localhost:3000/forms/chromium/convert/html \
--form files=@/path/to/index.html \
--form files=@/path/to/styles.css \
--form files=@/path/to/logo.png \
--form printBackground=true \
-o styled-output.pdf
```
--------------------------------
### Configure Tracing with OTLP
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/telemetry.mdx
Configure Gotenberg to export traces using OTLP. Ensure the OpenTelemetry Collector is running and accessible at the specified endpoint.
```yaml
services:
gotenberg:
image: gotenberg/gotenberg:8
environment:
OTEL_SERVICE_NAME: "gotenberg"
OTEL_TRACES_EXPORTER: "otlp"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4317"
otel-collector:
image: otel/opentelemetry-collector-contrib
# Configure your collector pipeline as needed.
```
--------------------------------
### Async Conversion with Webhook
Source: https://context7.com/gotenberg/gotenberg.dev/llms.txt
Use webhook headers for asynchronous processing of large files or batch operations. Gotenberg returns 204 immediately and POSTs the result to your callback URL.
```bash
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--header 'Gotenberg-Webhook-Url: https://my.webhook/success' \
--header 'Gotenberg-Webhook-Events-Url: https://my.webhook/events' \
--header 'Gotenberg-Webhook-Extra-Http-Headers: {"Authorization": "Bearer token123"}' \
--form url=https://example.com
```
--------------------------------
### POST /forms/libreoffice/convert
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-libreoffice/convert-to-pdf.mdx
Convert a document to PDF and set PDF viewer preferences.
```APIDOC
## POST /forms/libreoffice/convert
### Description
Convert a document to PDF and embed viewer preferences.
### Method
POST
### Endpoint
/forms/libreoffice/convert
### Parameters
#### Form Fields
- **files** (file) - Required - The document file to convert.
- **initialView** (integer) - Optional - Initial view when opening the PDF. 0: neither document outline nor thumbnails. 1: document outline visible. 2: thumbnail images visible. (Default: 0)
- **initialPage** (integer) - Optional - The page on which the PDF opens. (Default: 1)
- **magnification** (integer) - Optional - Initial magnification level. 0: default. 1: fit page. 2: fit width. 3: fit visible. 4: use zoom value. (Default: 0)
- **zoom** (integer) - Optional - Initial zoom percentage when magnification is set to 4. (Default: 100)
- **pageLayout** (integer) - Optional - Page layout. 0: default. 1: single page. 2: one column. 3: two columns. (Default: 0)
- **firstPageOnLeft** (boolean) - Optional - Place the first page on the left when using two-column page layout. (Default: false)
- **resizeWindowToInitialPage** (boolean) - Optional - Resize the viewer window to the size of the first page. (Default: false)
- **centerWindow** (boolean) - Optional - Center the viewer window on the screen. (Default: false)
- **openInFullScreenMode** (boolean) - Optional - Open the PDF in full-screen mode. (Default: false)
- **displayPDFDocumentTitle** (boolean) - Optional - Display the document title in the viewer title bar instead of the filename. (Default: true)
- **hideViewerMenubar** (boolean) - Optional - Hide the viewer menu bar. (Default: false)
- **hideViewerToolbar** (boolean) - Optional - Hide the viewer toolbar. (Default: false)
- **hideViewerWindowControls** (boolean) - Optional - Hide the viewer window controls. (Default: false)
- **useTransitionEffects** (boolean) - Optional - Use transition effects when advancing slides in Impress presentations. (Default: true)
- **openBookmarkLevels** (integer) - Optional - Number of bookmark levels to show when opening the PDF. -1 shows all levels. (Default: -1)
### Request Example
```bash
curl \
--request POST http://localhost:3000/forms/libreoffice/convert \
--form files=@/path/to/document.docx \
--form initialView=1 \
--form magnification=2 \
--form displayPDFDocumentTitle=true \
--form hideViewerToolbar=true \
-o my.pdf
```
### Response
#### Success Response (200)
- **file** (file) - The converted PDF file.
```
--------------------------------
### Convert Document with Specific LibreOffice Options
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-libreoffice/convert-to-pdf.mdx
Use this endpoint to convert documents with LibreOffice, specifying options for bookmark export and index updates. Ensure the original document is correctly formatted for bookmark generation.
```curl
curl \
--request POST http://localhost:3000/forms/libreoffice/convert \
--form files=@/path/to/document.docx \
--form exportBookmarks=false \
--form exportBookmarksToPdfDestination=true \
--form updateIndexes=false \
-o my.pdf
```
--------------------------------
### Document Outline (LibreOffice)
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-libreoffice/convert-to-pdf.mdx
Configure how LibreOffice generates PDF bookmarks and internal indexes.
```APIDOC
## Document Outline (LibreOffice)
### Description
Configure how LibreOffice generates PDF bookmarks (the sidebar) and internal indexes like the Table of Contents. Your source document must use proper heading styles (e.g., Heading 1, Heading 2) or explicit bookmarks to generate the hierarchy.
### Method
POST
### Endpoint
/forms/libreoffice/convert
### Parameters
#### Request Body
- **updateIndexes** (boolean) - Optional - Updates indexes (e.g., Table of Contents) before conversion. May cause missing links. (Default: true)
- **exportBookmarks** (boolean) - Optional - Exports bookmarks to the PDF. (Default: true)
- **exportBookmarksToPdfDestination** (boolean) - Optional - Exports bookmarks as Named Destinations. (Default: false)
- **addOriginalDocumentAsStream** (boolean) - Optional - Embeds the original document as a stream in the PDF for archiving. (Default: false)
### Request Example
```json
{
"updateIndexes": false,
"exportBookmarks": false,
"exportBookmarksToPdfDestination": true
}
```
### Response
#### Success Response (200)
- **file** (file) - The converted PDF file.
### Example Request (cURL)
```bash
curl \
--request POST http://localhost:3000/forms/libreoffice/convert \
--form files=@/path/to/document.docx \
--form exportBookmarks=false \
--form exportBookmarksToPdfDestination=true \
--form updateIndexes=false \
-o my.pdf
```
```
--------------------------------
### Configure LibreOffice Language to German (Gotenberg 8.23.1+)
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/configuration.mdx
Use this Dockerfile to set the German language for LibreOffice conversions in Gotenberg versions 8.23.1 and later. Ensure you update the base image tag accordingly.
```docker
FROM gotenberg/gotenberg:8
USER root
RUN apt-get update -qq &&\
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends -t trixie-backports libreoffice-l10n-de &&\
sed -i '/de_DE.UTF-8/s/^# //g' /etc/locale.gen &&\
locale-gen &&\
# Cleanup.
# Note: the Debian image does automatically a clean after each install thanks to a hook.
# Therefore, there is no need for apt-get clean.
# See https://stackoverflow.com/a/24417119/3248473.
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENV LANG de_DE.UTF-8
ENV LANGUAGE de_DE:de
ENV LC_ALL de_DE.UTF-8
USER gotenberg
```
--------------------------------
### Convert URL to PDF with Custom Layout
Source: https://context7.com/gotenberg/gotenberg.dev/llms.txt
Converts a URL to PDF with custom page layout and margins. Specify paper dimensions and margins for precise control over the output.
```bash
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://example.com \
--form paperWidth=8.27 \
--form paperHeight=11.7 \
--form marginTop=1 \
--form marginBottom=1 \
--form printBackground=true \
--form landscape=false \
-o document.pdf
```
--------------------------------
### Configure LibreOffice Language to German (Prior Gotenberg 8.22.0)
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/configuration.mdx
Use this Dockerfile to set the German language for LibreOffice conversions in Gotenberg versions prior to 8.22.0. Ensure you update the base image tag accordingly.
```docker
FROM gotenberg/gotenberg:8
USER root
RUN apt-get update -qq &&\
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends -t bookworm-backports libreoffice-l10n-de &&\
sed -i '/de_DE.UTF-8/s/^# //g' /etc/locale.gen &&\
locale-gen &&\
# Cleanup.
# Note: the Debian image does automatically a clean after each install thanks to a hook.
# Therefore, there is no need for apt-get clean.
# See https://stackoverflow.com/a/24417119/3248473.
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENV LANG de_DE.UTF-8
ENV LANGUAGE de_DE:de
ENV LC_ALL de_DE.UTF-8
USER gotenberg
```
--------------------------------
### Document Outline (Chromium)
Source: https://github.com/gotenberg/gotenberg.dev/blob/main/docs/convert-with-chromium/_shared/_structure_metadata.mdx
Automatically creates a PDF bookmark pane (sidebar) based on your HTML headings (`` to ``). Your HTML must use proper heading tags to generate the hierarchy.
```APIDOC
## POST /convert/html
### Description
Automatically creates a PDF bookmark pane (sidebar) based on your HTML headings (`` to ``). Your HTML must use proper heading tags to generate the hierarchy.
### Method
POST
### Endpoint
/convert/html
### Parameters
#### Request Body
- **generateDocumentOutline** (boolean) - Optional - Embeds the document outline (bookmarks) into the PDF. Defaults to false.
### Request Example
```json
{
"example": "form-data: generateDocumentOutline=true"
}
```
### Response
#### Success Response (200)
- **file** (file) - The generated PDF file.
#### Response Example
```json
{
"example": "[binary data]"
}
```
```
--------------------------------
### Capture Full-Page Screenshot with Custom Format
Source: https://context7.com/gotenberg/gotenberg.dev/llms.txt
Captures a full-page screenshot of a URL with specified format, width, and height. Useful for capturing entire web pages.
```bash
curl \
--request POST http://localhost:3000/forms/chromium/screenshot/url \
--form url=https://example.com \
--form format=png \
--form fullPage=true \
--form width=1920 \
--form height=1080 \
-o fullpage.png
```