Optimize PDFs
Reduces the file size of one or more PDF files by re-encoding their images to JPEG. Text, vectors, fonts, and structure are left untouched.
See the PDF Engines module configuration for engine selection flags.
Only lossless images above a size threshold are re-encoded. Already-compressed, transparent, and CMYK images are skipped, so the optimization never enlarges a file or breaks transparency.
Basics
POST/forms/pdfengines/optimize
Headers
Gotenberg-Output-Filenamestring
The filename of the resulting file - Gotenberg automatically appends the file extension. Defaults to a random UUID filename.
Gotenberg-Tracestring
A custom request ID to identify the request in the logs; overrides the default UUID.
Form Fields
imageQualityinteger
The JPEG quality applied to each re-encoded image, between 1 and 100. Defaults to 80.
Form Files
filesfile[]required
PDF files to optimize.
Example Request
cURL
curl \
--request POST http://localhost:3000/forms/pdfengines/optimize \
--form files=@/path/to/my.pdf \
--form imageQuality=80 \
-o my.pdf
Responses
- 200
- 400
- 503
The optimized PDF file. Multiple input files produce a ZIP archive.
Content-Disposition: attachment; filename={output-filename.ext}
Content-Type: {content-type}
Content-Length: {content-length}
Gotenberg-Trace: {trace}
Body: {output-file}
The request had one or more invalid form fields.
Content-Type: text/plain; charset=UTF-8
Gotenberg-Trace: {trace}
Body: {error}
The request did not complete within the configured maximum duration.
Content-Type: text/plain; charset=UTF-8
Gotenberg-Trace: {trace}
Body: {error}