### Start Gotenberg Container and Convert URL to PDF
Source: https://gotenberg.dev/docs/getting-started/introduction
Use Docker to start the Gotenberg container and then use curl to convert a URL to a PDF file. Ensure the container is running before making the request.
```bash
# 1. Start the container.
docker run --rm -p "3000:3000" gotenberg/gotenberg:8
# 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
```
--------------------------------
### Example Header/Footer HTML Structure
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-html-to-pdf
This is an example of a complete HTML document structure for headers and footers. It includes basic styling and placeholders for dynamic content like page numbers.
```html
Page of
```
--------------------------------
### Version API Response Example
Source: https://gotenberg.dev/docs/system/version
This is an example of a successful response from the /version endpoint. It includes the Gotenberg version and a trace ID for request identification.
```http
Content-Type: text/plain; charset=UTF-8
Gotenberg-Trace: {trace}
{semver}
```
--------------------------------
### Run Gotenberg with Docker
Source: https://gotenberg.dev/docs/getting-started/installation
This command starts a Gotenberg container, exposing the API on port 3000. For enhanced security, bind it 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
```
--------------------------------
### Try the Live Demo API
Source: https://gotenberg.dev/docs/getting-started/installation
Use this command to test Gotenberg's API without any installation. It converts a URL to a PDF using 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
```
--------------------------------
### JavaScript Example for Wait For Expression
Source: https://gotenberg.dev/docs/convert-with-chromium/screenshot-markdown
This JavaScript code demonstrates how to signal Gotenberg that a page is ready for screenshot by setting window.status to 'ready' after asynchronous operations complete.
```javascript
// Inside your HTML page.
window.status = "loading";
fetchData().then(() => {
renderCharts();
// Signal to Gotenberg that the page is ready.
window.status = "ready";
});
```
--------------------------------
### Get Debug Information
Source: https://gotenberg.dev/docs/system/debug
Retrieves the runtime configuration, active modules, and dependency versions. This endpoint is useful for troubleshooting and verifying startup flags. It is 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
#### Gotenberg-Trace
- **string** - Optional - A custom request ID to identify the request in the logs; overrides the default UUID.
### Request Example
```curl
curl --request GET http://localhost:3000/debug
```
### Response
#### Success Response (200)
- **Details**: The response body contains a JSON object with the runtime configuration, active modules, and dependency versions.
```
--------------------------------
### Split PDF by Pages and Add Metadata
Source: https://gotenberg.dev/docs/manipulate-pdfs/split-pdfs
This example demonstrates splitting a PDF by page ranges and simultaneously injecting XMP metadata such as Author, Title, and Keywords. Ensure the metadata keys are valid according to ExifTool documentation.
```shell
curl \
--request POST http://localhost:3000/forms/pdfengines/split \
--form files=@/path/to/file.pdf \
--form splitMode=intervals \
--form splitSpan=1 \
--form 'metadata={"Author":"Julien Neuhart","Copyright":"Julien Neuhart","CreationDate":"2006-09-18T16:27:50-04:00","Creator":"Gotenberg","Keywords":["first","second"],"Marked":true,"ModDate":"2006-09-18T16:27:50-04:00","PDFVersion":1.7,"Producer":"Gotenberg","Subject":"Sample","Title":"Sample","Trapped":"Unknown"}' \
-o my.zip
```
--------------------------------
### Add Stamp with Options
Source: https://gotenberg.dev/docs/manipulate-pdfs/split-pdfs
Applies a text stamp on top of the content of each page. This example shows how to configure the stamp's opacity and rotation. The stamp expression is provided as text.
```cURL
curl \
--request POST http://localhost:3000/forms/pdfengines/split \
--form files=@/path/to/file.pdf \
--form splitMode=intervals \
--form splitSpan=1 \
--form stampSource=text \
--form stampExpression=APPROVED \
--form 'stampOptions={"opacity":0.5,"rotation":0}' \
-o my.zip
```
--------------------------------
### URL to PDF Conversion with Page Layout Options
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-url-to-pdf
This example demonstrates how to convert a URL to PDF while specifying custom page dimensions, margins, orientation, and scale. Adjust these parameters to control the final PDF's layout.
```curl
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://my.url \
--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 \
-o my.pdf
```
--------------------------------
### Split PDF with User and Owner Passwords
Source: https://gotenberg.dev/docs/manipulate-pdfs/split-pdfs
This example demonstrates how to split a PDF file and apply both a user password for opening the document and an owner password to control permissions like printing and editing. This is ideal for securing sensitive documents during the splitting process.
```bash
curl \
--request POST http://localhost:3000/forms/pdfengines/split \
--form files=@/path/to/file.pdf \
--form splitMode=intervals \
--form splitSpan=1 \
--form userPassword=my_user_password \
--form ownerPassword=my_owner_password \
-o my.zip
```
--------------------------------
### Encrypt PDF with Passwords using cURL
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-url-to-pdf
Example cURL request to convert a URL to PDF and apply both user and owner passwords for access control and permission management.
```curl
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://my.url \
--form userPassword=my_user_password \
--form ownerPassword=my_owner_password \
-o my.pdf
```
--------------------------------
### Configure LibreOffice Language to German (Gotenberg 8.23.1+)
Source: https://gotenberg.dev/docs/configuration
This Dockerfile snippet demonstrates how to build a custom Gotenberg Docker image with German language support for LibreOffice conversions. It installs the necessary language pack and sets environment variables for locale.
```Dockerfile
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
```
--------------------------------
### Customizing HTTP Headers and User-Agent
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-url-to-pdf
This example shows how to override the default User-Agent and set custom HTTP headers, including scoped headers, for the URL conversion request.
```bash
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://my.url \
--form 'userAgent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)"' \
--form-string 'extraHttpHeaders={"X-Header":"value","X-Scoped-Header":"value;scope=https?://([a-zA-Z0-9-]+\\.)*domain\\.com/.*"}' \
-o my.pdf
```
--------------------------------
### cURL Request with Assets for Markdown Screenshot
Source: https://gotenberg.dev/docs/convert-with-chromium/screenshot-markdown
This cURL example demonstrates how to include additional assets like images alongside the HTML template and Markdown file. All uploaded files are stored in a single flat directory within the container.
```bash
curl \
--request POST http://localhost:3000/forms/chromium/screenshot/markdown \
--form files=@/path/to/index.html \
--form files=@/path/to/file.md \
--form files=@/path/to/img.png \
-o my.jpeg
```
--------------------------------
### cURL Request with Webhook Headers
Source: https://gotenberg.dev/docs/webhook-download
Example of sending a request to Gotenberg with webhook headers for asynchronous processing and event notifications. Includes setting a success URL, an events URL, and custom HTTP headers.
```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 123"}' \
--form url=https://my.url
```
--------------------------------
### Build Custom Docker Image with Microsoft Core Fonts
Source: https://gotenberg.dev/docs/configuration
Use this Dockerfile to install Microsoft Core Fonts in a custom Gotenberg image. Ensure you accept the Microsoft EULA.
```dockerfile
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
```
--------------------------------
### cURL Example for Watermarking a PDF
Source: https://gotenberg.dev/docs/manipulate-pdfs/watermark-pdfs
This cURL command demonstrates how to watermark a PDF file using Gotenberg. It specifies the watermark source as text and includes custom opacity and rotation options.
```bash
curl \
--request POST http://localhost:3000/forms/pdfengines/watermark \
--form files=@/path/to/file.pdf \
--form watermarkSource=text \
--form watermarkExpression=CONFIDENTIAL \
--form 'watermarkOptions={"opacity":0.25,"rotation":45}' \
-o my.pdf
```
--------------------------------
### Convert to PDF/A and PDF/UA using cURL
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-url-to-pdf
Example cURL request to convert a URL to PDF, applying both PDF/A-1b archival standard and PDF/UA accessibility compliance.
```curl
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://my.url \
--form pdfa=PDF/A-1b \
--form pdfua=true \
-o my.pdf
```
--------------------------------
### Download File from Remote URL using cURL
Source: https://gotenberg.dev/docs/webhook-download
This cURL command demonstrates how to use the `downloadFrom` form field to instruct Gotenberg to fetch a file from a specified URL. It includes an example of passing custom HTTP headers.
```shell
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
```
--------------------------------
### Docker Compose Setup for Telemetry Export
Source: https://gotenberg.dev/docs/telemetry
This Docker Compose configuration sets up Gotenberg to export traces, metrics, and logs to an OpenTelemetry Collector. Ensure the OTEL_EXPORTER_OTLP_ENDPOINT matches your collector's address.
```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
```
--------------------------------
### Configure LibreOffice Language to German (Prior Gotenberg 8.22.0)
Source: https://gotenberg.dev/docs/configuration
This Dockerfile snippet shows how to build a custom Gotenberg Docker image with German language support for LibreOffice conversions for versions prior to 8.22.0. It installs the required language pack and configures locale environment variables.
```Dockerfile
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
```
--------------------------------
### Get Gotenberg Version
Source: https://gotenberg.dev/docs/system/version
Use this cURL command to make a GET request to the /version endpoint. This is useful for verifying that Gotenberg is running and accessible.
```curl
curl --request GET http://localhost:3000/version
```
--------------------------------
### Convert Document to PDF with Bookmark Options
Source: https://gotenberg.dev/docs/convert-with-libreoffice/convert-to-pdf
This snippet demonstrates converting a document to PDF while configuring bookmark and index export settings. Control whether indexes are updated and how bookmarks are exported.
```shell
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
```
--------------------------------
### Convert Document with Viewer Preferences
Source: https://gotenberg.dev/docs/convert-with-libreoffice/convert-to-pdf
Convert a document to PDF and set viewer preferences such as initial view, magnification, and toolbar visibility. These settings control how the PDF is displayed when opened.
```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
```
--------------------------------
### ApiEndpoint Component Usage
Source: https://gotenberg.dev/docs
Use the ApiEndpoint component to document API endpoints. Specify the HTTP method, path, headers, form fields, cURL example, and responses. Ensure the cURL example is valid and copy-pasteable.
```javascript
```
--------------------------------
### Get Prometheus Metrics
Source: https://gotenberg.dev/docs/system/prometheus-metrics
Retrieves internal metrics in Prometheus format. This endpoint is deprecated.
```APIDOC
## GET /prometheus/metrics
### Description
Exposes internal metrics in Prometheus format. This endpoint is deprecated.
### 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
```curl
curl --request GET http://localhost:3000/prometheus/metrics
```
### Response
#### Success Response (200)
- **metrics** (object) - The metrics in Prometheus format. See https://demo.gotenberg.dev/prometheus/metrics for details.
```
--------------------------------
### Get Prometheus Metrics
Source: https://gotenberg.dev/docs/system/prometheus-metrics
Use this cURL command to retrieve internal metrics from the /prometheus/metrics endpoint. This endpoint is deprecated.
```shell
curl --request GET http://localhost:3000/prometheus/metrics
```
--------------------------------
### JavaScript for Wait For Expression
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-markdown-to-pdf
Example JavaScript code to set a status flag, signaling when dynamic content is ready for PDF conversion.
```javascript
// Inside your HTML page.
window.status = "loading";
fetchData().then(() => {
renderCharts();
// Signal to Gotenberg that the page is ready.
window.status = "ready";
});
```
--------------------------------
### Rotate PDF Pages (cURL)
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-html-to-pdf
Example cURL request to convert HTML to PDF and rotate specific pages by 90 degrees.
```curl
curl \
--request POST http://localhost:3000/forms/chromium/convert/html \
--form files=@/path/to/index.html \
--form rotateAngle=90 \
-o my.pdf
```
--------------------------------
### Generate Tagged PDF for Accessibility (cURL)
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-html-to-pdf
Example cURL request to convert HTML to PDF and enable native accessibility tagging for screen readers.
```curl
curl \
--request POST http://localhost:3000/forms/chromium/convert/html \
--form files=@/path/to/index.html \
--form generateTaggedPdf=true \
-o my.pdf
```
--------------------------------
### Add Text Stamp to PDF (cURL)
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-html-to-pdf
Example cURL request to convert HTML to PDF and add a text stamp with custom opacity and rotation.
```curl
curl \
--request POST http://localhost:3000/forms/chromium/convert/html \
--form files=@/path/to/index.html \
--form stampSource=text \
--form stampExpression=APPROVED \
--form 'stampOptions={"opacity":0.5,"rotation":0}' \
-o my.pdf
```
--------------------------------
### Convert URL to PDF with Emulated Screen Media
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-url-to-pdf
Use this snippet to convert a URL to PDF while emulating the 'screen' media type, which typically includes background colors and images as seen in a browser. This is useful when the PDF should visually match the browser's rendering.
```bash
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://my.url \
--form emulatedMediaType=screen \
-o my.pdf
```
--------------------------------
### Add Text Watermark to PDF (cURL)
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-html-to-pdf
Example cURL request to convert HTML to PDF and add a text watermark with custom opacity and rotation.
```curl
curl \
--request POST http://localhost:3000/forms/chromium/convert/html \
--form files=@/path/to/index.html \
--form watermarkSource=text \
--form watermarkExpression=CONFIDENTIAL \
--form 'watermarkOptions={"opacity":0.25,"rotation":45}' \
-o my.pdf
```
--------------------------------
### JavaScript for Wait For Selector
Source: https://gotenberg.dev/docs/convert-with-chromium/screenshot-url
Example JavaScript code to create and append a DOM element with a specific ID. This element serves as a marker for the `waitForSelector` option.
```javascript
// Inside your HTML page.
await heavyCalculation();
const completionMarker = document.createElement("div");
completionMarker.id = "app-ready"; // The selector we wait for.
document.body.appendChild(completionMarker);
```
--------------------------------
### Convert Document to PDF with Metadata Injection
Source: https://gotenberg.dev/docs/convert-with-libreoffice/convert-to-pdf
This snippet shows how to inject XMP metadata into a PDF during conversion. Provide metadata as a JSON object, but note that this may break PDF/A compliance.
```shell
curl \
--request POST http://localhost:3000/forms/libreoffice/convert \
--form files=@/path/to/document.docx \
--form 'metadata={"Author":"Julien Neuhart","Copyright":"Julien Neuhart","CreationDate":"2006-09-18T16:27:50-04:00","Creator":"Gotenberg","Keywords":["first","second"],"Marked":true,"ModDate":"2006-09-18T16:27:50-04:00","PDFVersion":1.7,"Producer":"Gotenberg","Subject":"Sample","Title":"Sample","Trapped":"Unknown"}' \
-o my.pdf
```
--------------------------------
### JavaScript for Wait For Expression
Source: https://gotenberg.dev/docs/convert-with-chromium/screenshot-url
Example JavaScript code to set a status flag, signaling when dynamic content is ready for conversion. This flag is used by `waitForExpression`.
```javascript
// Inside your HTML page.
window.status = "loading";
fetchData().then(() => {
renderCharts();
// Signal to Gotenberg that the page is ready.
window.status = "ready";
});
```
--------------------------------
### Convert URL to PDF with Background Rendering Options
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-url-to-pdf
Converts a URL to PDF, allowing control over background graphics and colors, including options for transparency.
```APIDOC
## POST /forms/chromium/convert/url (with Background Logic)
### Description
Converts a target URL to PDF with options to control background rendering.
### Method
POST
### Endpoint
/forms/chromium/convert/url
### Headers
- **Gotenberg-Filename** (string) - Optional - The filename of the resulting file. Defaults to a random UUID filename.
- **Gotenberg-Trace** (string) - Optional - A custom request ID to identify the request in the logs; overrides the default UUID.
### Form Fields
- **url** (string) - Required - URL of the page to convert into PDF.
- **printBackground** (boolean) - Optional - Includes background graphics/colors from the HTML. Default: `false`.
- **omitBackground** (boolean) - Optional - Hides the default white background (allows transparency). Default: `false`.
### Request Example
```curl
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://my.url \
--form printBackground=true \
-o my.pdf
```
### Background Logic Explanation
- `printBackground=false` (Any `omitBackground`): No Background.
- `printBackground=true`, HTML CSS has BG (Yes) (Any `omitBackground`): Uses HTML CSS Background.
- `printBackground=true`, `omitBackground=true`, HTML CSS has BG (No): Transparent.
- `printBackground=true`, `omitBackground=false`, HTML CSS has BG (No): White (Default).
**Note**: When `singlePage` is `true`, it overrides `paperHeight` and `nativePageRanges`.
```
--------------------------------
### Successful Metadata Response
Source: https://gotenberg.dev/docs/manipulate-pdfs/read-metadata
This is an example of a successful JSON response containing metadata extracted from PDF files. The keys correspond to ExifTool tag names.
```json
{
"invoice.pdf": {
"PDFVersion": 1.7,
"Author": "Gotenberg",
"Title": "Invoice #001",
"CreateDate": "2024:03:05 09:15:32Z",
"PageCount": 2,
"Producer": "Gotenberg",
"MIMEType": "application/pdf"
},
"report.pdf": {
"PDFVersion": 1.4,
"Author": "John Doe",
"PageCount": 15
// ...
}
}
```
--------------------------------
### Configure Traces Export with OTLP
Source: https://gotenberg.dev/docs/telemetry
Set environment variables to export traces using the OTLP protocol. Ensure the OTEL_EXPORTER_OTLP_ENDPOINT is correctly configured to point to your OpenTelemetry collector.
```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.
```
--------------------------------
### Get Gotenberg Version
Source: https://gotenberg.dev/docs/system/version
Retrieves the version of the running Gotenberg instance. This is useful for verifying deployments. Custom variants may not print strict semver.
```APIDOC
## GET /version
### Description
Returns the version of the running Gotenberg instance. Useful for verifying deployments.
### Method
GET
### Endpoint
/version
### Headers
- **Gotenberg-Trace** (string) - A custom request ID to identify the request in the logs; overrides the default UUID.
### Request Example
```curl
curl --request GET http://localhost:3000/version
```
### Response
#### Success Response (200)
- **Body** (string) - The Gotenberg version.
- **Gotenberg-Trace** (string) - The trace ID for the request.
#### Response Example
```
Content-Type: text/plain; charset=UTF-8
Gotenberg-Trace: {trace}
{semver}
```
```
--------------------------------
### cURL Request for Markdown to PDF with Rotation
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-markdown-to-pdf
Example cURL command to convert Markdown to PDF using the Chromium engine, rotating pages by 90 degrees.
```curl
curl \
--request POST http://localhost:3000/forms/chromium/convert/markdown \
--form files=@/path/to/index.html \
--form files=@/path/to/file.md \
--form rotateAngle=90 \
-o my.pdf
```
--------------------------------
### Convert HTML to PDF with Metadata
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-html-to-pdf
Use this cURL command to convert an HTML file to PDF and inject XMP metadata. The metadata is provided as a JSON object in the 'metadata' form field.
```bash
curl \
--request POST http://localhost:3000/forms/chromium/convert/html \
--form files=@/path/to/index.html \
--form 'metadata={"Author":"Julien Neuhart","Copyright":"Julien Neuhart","CreationDate":"2006-09-18T16:27:50-04:00","Creator":"Gotenberg","Keywords":["first","second"],"Marked":true,"ModDate":"2006-09-18T16:27:50-04:00","PDFVersion":1.7,"Producer":"Gotenberg","Subject":"Sample","Title":"Sample","Trapped":"Unknown"}' \
-o my.pdf
```
--------------------------------
### Convert Markdown to PDF with Metadata
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-markdown-to-pdf
This cURL command shows how to convert Markdown to PDF and embed custom XMP metadata into the PDF.
```bash
curl \
--request POST http://localhost:3000/forms/chromium/convert/markdown \
--form files=@/path/to/index.html \
--form files=@/path/to/file.md \
--form 'metadata={"Author":"Julien Neuhart","Copyright":"Julien Neuhart","CreationDate":"2006-09-18T16:27:50-04:00","Creator":"Gotenberg","Keywords":["first","second"],"Marked":true,"ModDate":"2006-09-18T16:27:50-04:00","PDFVersion":1.7,"Producer":"Gotenberg","Subject":"Sample","Title":"Sample","Trapped":"Unknown"}' \
-o my.pdf
```
--------------------------------
### cURL Request for Markdown to PDF with Stamp
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-markdown-to-pdf
Example cURL command to convert Markdown to PDF using the Chromium engine, applying a text stamp with custom options.
```curl
curl \
--request POST http://localhost:3000/forms/chromium/convert/markdown \
--form files=@/path/to/index.html \
--form files=@/path/to/file.md \
--form stampSource=text \
--form stampExpression=APPROVED \
--form 'stampOptions={"opacity":0.5,"rotation":0}' \
-o my.pdf
```
--------------------------------
### Convert Document to PDF with Image Compression Options
Source: https://gotenberg.dev/docs/convert-with-libreoffice/convert-to-pdf
Use this snippet to convert a document to PDF while controlling image compression settings. Specify lossless or lossy compression and JPEG quality.
```shell
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
```
--------------------------------
### cURL Request for Markdown to PDF with Watermark
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-markdown-to-pdf
Example cURL command to convert Markdown to PDF using the Chromium engine, applying a text watermark with custom options.
```curl
curl \
--request POST http://localhost:3000/forms/chromium/convert/markdown \
--form files=@/path/to/index.html \
--form files=@/path/to/file.md \
--form watermarkSource=text \
--form watermarkExpression=CONFIDENTIAL \
--form 'watermarkOptions={"opacity":0.25,"rotation":45}' \
-o my.pdf
```
--------------------------------
### Convert URL to PDF with Metadata
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-url-to-pdf
Inject XMP metadata into the PDF by providing a JSON object to the 'metadata' field. Note that writing metadata might affect PDF/A compliance.
```cURL
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://my.url \
--form 'metadata={"Author":"Julien Neuhart","Copyright":"Julien Neuhart","CreationDate":"2006-09-18T16:27:50-04:00","Creator":"Gotenberg","Keywords":["first","second"],"Marked":true,"ModDate":"2006-09-18T16:27:50-04:00","PDFVersion":1.7,"Producer":"Gotenberg","Subject":"Sample","Title":"Sample","Trapped":"Unknown"}' \
-o my.pdf
```
--------------------------------
### Generate Tagged PDF for Accessibility using cURL
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-url-to-pdf
Example cURL request to convert a URL to PDF and enable native accessibility tagging using the 'generateTaggedPdf' option.
```curl
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://my.url \
--form generateTaggedPdf=true \
-o my.pdf
```
--------------------------------
### Convert URL to PDF with Page Splitting
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-url-to-pdf
Use this cURL command to convert a URL to a PDF and split it into intervals. Ensure the Gotenberg server is running and accessible.
```shell
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://my.url \
--form splitMode=intervals \
--form splitSpan=1 \
-o my.zip
```
--------------------------------
### Convert URL to PDF with Emulated Media Features
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-url-to-pdf
This snippet demonstrates how to convert a URL to PDF while emulating specific CSS media features like 'prefers-color-scheme' and 'prefers-reduced-motion'. This is useful for testing how a web page adapts to different user preferences or accessibility settings.
```bash
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://my.url \
--form emulatedMediaFeatures='[{"name": "prefers-color-scheme", "value": "dark"}, {"name": "prefers-reduced-motion", "value": "reduce"}]' \
-o my.pdf
```
--------------------------------
### POST /forms/chromium/screenshot/markdown (with console exception handling)
Source: https://gotenberg.dev/docs/convert-with-chromium/screenshot-markdown
Converts markdown content to a screenshot, failing if any exceptions occur in the Chromium console.
```APIDOC
## POST /forms/chromium/screenshot/markdown
### Description
Converts markdown content to a screenshot, failing if any exceptions occur in the Chromium console.
### Method
POST
### Endpoint
/forms/chromium/screenshot/markdown
### Parameters
#### Form Parameters
- **files** (file) - Required - The markdown file(s) to convert.
- **failOnConsoleExceptions** (boolean) - Optional - If true, returns a 409 Conflict response if there are exceptions in the Chromium console. Defaults to false.
### Request Example
```curl
curl \
--request POST http://localhost:3000/forms/chromium/screenshot/markdown \
--form files=@/path/to/index.html \
--form files=@/path/to/file.md \
--form failOnConsoleExceptions=true \
-o my.jpeg
```
### Response
#### Success Response (200)
- **Output** (file) - The generated screenshot image.
#### Error Responses
- **409 Conflict**: Returned if `failOnConsoleExceptions` is true and there are exceptions in the Chromium console.
- **400 Bad Request**: Returned for critical network errors or if `failOnResourceLoadingFailed` is true and assets fail to load.
- **403 Forbidden**: Returned for forbidden outbound URLs.
```
--------------------------------
### cURL Request for Markdown to PDF with Tagged PDF
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-markdown-to-pdf
Example cURL command to convert Markdown to PDF using the Chromium engine, enabling tagged PDF generation for accessibility.
```curl
curl \
--request POST http://localhost:3000/forms/chromium/convert/markdown \
--form files=@/path/to/index.html \
--form files=@/path/to/file.md \
--form generateTaggedPdf=true \
-o my.pdf
```
--------------------------------
### Convert URL to PDF with Metadata
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-url-to-pdf
Converts a URL to a PDF and injects XMP metadata such as Author, Title, Copyright, and Keywords. Note that writing metadata might affect PDF/A compliance.
```APIDOC
## POST /forms/chromium/convert/url
### Description
Converts a URL to a PDF and injects specified XMP metadata into the PDF document.
### Method
POST
### Endpoint
/forms/chromium/convert/url
### Parameters
#### Form Fields
- **url** (string) - Required - The URL to convert to PDF.
- **metadata** (json) - Optional - Writes metadata (Author, Title, etc.). Defaults to `None`.
### Request Example
```curl
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://my.url \
--form 'metadata={"Author":"Julien Neuhart","Copyright":"Julien Neuhart","CreationDate":"2006-09-18T16:27:50-04:00","Creator":"Gotenberg","Keywords":["first","second"],"Marked":true,"ModDate":"2006-09-18T16:27:50-04:00","PDFVersion":1.7,"Producer":"Gotenberg","Subject":"Sample","Title":"Sample","Trapped":"Unknown"}' \
-o my.pdf
```
```
--------------------------------
### HTML Screenshot with Correct Asset Reference
Source: https://gotenberg.dev/docs/convert-with-chromium/screenshot-html
Demonstrates the correct way to reference an image asset ('logo.png') within an HTML file when both are uploaded as separate form files.
```HTML
My PDF
Hello world!
```
--------------------------------
### Screenshot Markdown with Network Options
Source: https://gotenberg.dev/docs/convert-with-chromium/screenshot-markdown
Use this snippet to convert Markdown to a screenshot while controlling network idle behavior and resource loading failure handling. Set `skipNetworkIdleEvent` and `skipNetworkAlmostIdleEvent` to `false` to wait for network activity to settle. Set `failOnResourceLoadingFailed` to `true` to return a 400 error if assets fail to load.
```curl
curl \
--request POST http://localhost:3000/forms/chromium/screenshot/markdown \
--form files=@/path/to/index.html \
--form files=@/path/to/file.md \
--form skipNetworkIdleEvent=false \
--form skipNetworkAlmostIdleEvent=false \
--form failOnResourceLoadingFailed=true \
-o my.jpeg
```
--------------------------------
### Rotate PDF Pages using cURL
Source: https://gotenberg.dev/docs/convert-with-chromium/convert-url-to-pdf
Example cURL request to convert a URL to PDF and rotate specific pages by 90 degrees. The 'rotateAngle' and 'rotatePages' fields control the rotation.
```curl
curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://my.url \
--form rotateAngle=90 \
-o my.pdf
```
--------------------------------
### HTML Screenshot with Rendering Options
Source: https://gotenberg.dev/docs/convert-with-chromium/screenshot-html
Capture a screenshot with custom rendering parameters including dimensions, format, quality, and optimization for speed.
```cURL
curl \
--request POST http://localhost:3000/forms/chromium/screenshot/html \
--form files=@/path/to/index.html \
--form width=1280 \
--form height=720 \
--form format=jpeg \
--form quality=85 \
--form optimizeForSpeed=true \
-o my.jpeg
```