Skip to main content
Version: 9.x

Your first PDF

Three requests, three PDFs: a web page, your own HTML, and a Word document. Start Gotenberg first:

docker run --rm -p "3000:3000" gotenberg/gotenberg:9

Send the URL. Chromium loads the page as a browser would, then prints it:

curl \
--request POST http://localhost:3000/forms/chromium/convert/url \
--form url=https://example.com \
-o example.pdf

-o example.pdf saves the answer. Without it, cURL prints the PDF's bytes to your terminal.

Convert your own HTML​

Upload an index.html and the files it links to. Gotenberg serves them side by side, so a relative link such as style.css resolves:

curl \
--request POST http://localhost:3000/forms/chromium/convert/html \
--form files=@index.html \
--form files=@style.css \
-o invoice.pdf

The entry file must be named index.html. The other files keep their names.

Convert a Word document​

LibreOffice converts Word, Excel, PowerPoint, OpenDocument and many more formats:

curl \
--request POST http://localhost:3000/forms/libreoffice/convert \
--form files=@report.docx \
-o report.pdf

Upload several documents to get one PDF each, in a ZIP.

Add a stage​

A conversion can go further in the same request. The stages field lists the steps to run on the PDF, in order. This one makes the report a PDF/A-4, the ISO standard for archives: the file carries its fonts and colors, so it opens the same in decades.

curl \
--request POST http://localhost:3000/forms/libreoffice/convert \
--form files=@report.docx \
--form 'stages=[
{ "op": "remediate", "profile": "PDF/A-4" }
]' \
-o report.pdf
Response
HTTP/1.1 200 OK
Content-Type: application/pdf
Gotenberg-Remediation-Residual: 0
Gotenberg-Remediation-Rolled-Back: 0

Gotenberg-Remediation-Residual: 0 means no violation is left: the PDF conforms to PDF/A-4.

Next​

How requests work covers the rest of a request: archives, files to download, output names, ZIP answers and errors.