API Routes¶
Chromium¶
Access to the Chromium module of Gotenberg, as documented here.
URL into PDF¶
Route Access: client.chromium.url_to_pdf()
Required Properties:
.url("http://localhost:8888")
See also common Chromium options
HTML file into PDF¶
Route Access: client.chromium.html_to_pdf()
Required Properties:
- An index file is required:
.index("index.html")
sets the index from an HTML filestring_index(<html></html>")
sets the index as the HTML string
Optional Properties:
- Provide additional resource files as needed:
.resource("file-here")
orresources(["file1", "file2"])
adds the file or files as a resource for the HTML index- Add string resources with
string_resource("file content")
.
See also common Chromium options.
Note
string_resource
currently only supports text data, not binary data
Markdown file(s) into PDF¶
Route Access: chromium.markdown_to_pdf()
Required Properties:
- An index file is required:
.index("index.html")
sets the index from an HTML filestring_index(<html></html>")
sets the index as the HTML string
Optional Properties:
- Provide additional resource files as needed:
.resource("file-here")
orresources(["file1", "file2"])
adds the file or files as a resource for the HTML index- Add string resources with
string_resource("file content")
.
See also common Chromium options.
Note
string_resource
currently only supports text data, not binary data
Screenshot Routes¶
Common Settings¶
Gotenberg Option | Route Configuration | Python Type | Notes |
---|---|---|---|
width | .width() | int | |
height | height() | int | |
clip | clip() or clip_to_dimensions() or no_clip_to_dimensions() | bool | |
format | output_format() | one of "png", "jpeg" or "webp". | |
quality | quality() | int , between 1 and 100 | |
omitBackground | omit_background() or hide_background() or show_background() | bool | |
optimizeForSpeed | image_optimize() or image_optimize_for_speed() or image_optimize_for_quality | bool |
This route also supports other Chromium options:
- Wait Before Rendering
- Emulated Media Type
- Cookies
- Custom HTTP headers
- Invalid HTTP Status Codes
- Console Exceptions
- Performance Mode
Chromium Common Options¶
Page Properties¶
Gotenberg Option | Route Configuration | Python Type | Notes |
---|---|---|---|
singlePage | .single_page() | bool | Set via keyword only |
| .size() | PageSize | Current only allows size configuration in inches |
| .margin() | PageMarginsType | |
preferCssPageSize |
| N/A | |
printBackground |
| N/A | |
omitBackground |
| N/A | |
landscape | .orient() | PageOrientation | |
scale | scale() | int | float | |
nativePageRanges | page_ranges() | str |
Header & Footer¶
Gotenberg Option | Route Configuration | Python Type | Notes |
---|---|---|---|
header.html | .header() | Path | |
footer.html | .footer() | Path |
Render Control¶
Gotenberg Option | Route Configuration | Python Type | Notes |
---|---|---|---|
waitDelay | .render_wait() | int | float | |
waitForExpression | .render_expr() | str |
Emulated Media Type¶
Gotenberg Option | Route Configuration | Python Type | Notes |
---|---|---|---|
emulatedMediaType | .media_type() | EmulatedMediaType |
Cookies¶
Gotenberg Option | Route Configuration | Python Type | Notes |
---|---|---|---|
cookies | .cookies() | list[CookieJar] |
Custom HTTP Headers¶
Gotenberg Option | Route Configuration | Python Type | Notes |
---|---|---|---|
extraHttpHeaders | .headers() | dict[str, str] | The dictionary of values will be JSON encoded for you |
HTTP Status Codes¶
Gotenberg Option | Route Configuration | Python Type | Notes |
---|---|---|---|
failOnHttpStatusCodes | .fail_on_status_codes() | Iterable[int] |
Network Errors¶
Gotenberg Option | Route Configuration | Python Type | Notes |
---|---|---|---|
failOnResourceLoadingFailed | fail_on_resource_loading_failed | bool |
Console Exceptions¶
Gotenberg Option | Route Configuration | Python Type | Notes |
---|---|---|---|
failOnConsoleExceptions |
| N/A |
Performance Mode¶
Gotenberg Option | Route Configuration | Python Type | Notes |
---|---|---|---|
skipNetworkIdleEvent |
| N/A |
Split¶
Gotenberg Option | Route Configuration | Python Type | Notes |
---|---|---|---|
splitMode | .split_mode() | one of "pages", "intervals" | |
splitSpan | split_span() | str | |
splitUnify | split_unify() | bool |
PDF/A & PDF/UA¶
Gotenberg Option | Route Configuration | Python Type | Notes |
---|---|---|---|
pdfa | .pdf_format() | PdfAFormat | |
pdfua |
| N/A |
PDF Metadata Support¶
Add metadata to your PDFs:
from gotenberg_client import GotenbergClient
from datetime import datetime
with GotenbergClient("http://localhost:3000") as client:
with client.chromium.html_to_pdf() as route:
response = (route
.index("my-index.html")
.metadata(
title="My Document",
author="John Doe",
creation_date=datetime.now(),
keywords=["sample", "document"],
subject="Sample PDF Generation",
trapped="Unknown"
)
.run())
Supported metadata fields:
title
: Document titleauthor
: Document authorsubject
: Document subjectkeywords
: List of keywordscreator
: Creating applicationcreation_date
: Creation datetimemodification_date
: Last modification datetimeproducer
: PDF producertrapped
: Trapping status ('True', 'False', 'Unknown')copyright
: Copyright informationmarked
: PDF marked statuspdf_version
: PDF version number
Note
Some fields cannot be set or will be overwritten, depending on Gotenberg and its utilized PDF engine
LibreOffice¶
Office Documents to PDF¶
Gotenberg Link | Route Access | Required Properties | Optional Properties |
---|---|---|---|
Documentation | libre_office.to_pdf |
| See common LibreOffice options |
Note
convert
may be called multiple times" !!! note "convert_files
is a convenience method to convert a list of file into PDF
LibreOffice Properties¶
Page Properties¶
Gotenberg Option | Route Configuration | Python Type | Notes |
---|---|---|---|
landscape | .orient() | PageOrientation | |
nativePageRanges | page_ranges() | str | |
exportFormFields | N/A | N/A | This option is not implemented yet |
singlePageSheets | N/A | N/A | This option is not implemented yet |
Compress¶
Merge¶
Gotenberg Option | Route Configuration | Python Type | Notes |
---|---|---|---|
merge |
| N/A |
Note
If multiple files are provided, and the merge is left as default or no_merge()
is called, the resulting file will be a zip
Split¶
PDF/A & PDF/UA¶
Gotenberg Option | Route Configuration | Python Type | Notes |
---|---|---|---|
pdfa | .pdf_format() | PdfAFormat | |
pdfua |
| N/A |
Metadata¶
See PDF Metadata Support for the API interface.
Flatten¶
Convert into PDF/A & PDF/UA¶
Gotenberg Link | Route Access | Required Properties | Optional Properties |
---|---|---|---|
pdfa | .pdf_format() | PdfAFormat | |
pdfua |
| N/A |
Note
At least one of pdf_format()
, enable_universal_access()
or disable_universal_access()
must be set
Read PDF metadata¶
Write PDF metadata¶
Merge PDFs¶
Gotenberg Link | Route Access | Required Properties | Optional Properties |
---|---|---|---|
pdfa | .pdf_format() | PdfAFormat | |
pdfua |
| N/A | |
metadata | N/A | N/A | See PDF Metadata Support for the API interface. |
Note
Prefixes will be added to the file to ensure they are merged in the order provided to merge()
, even with multiple calls
Split PDFs¶
Flatten PDFs¶
Health Check¶
Metrics¶
Warning
This route is not implemented
Version¶
Warning
This route is not implemented
Debug¶
Warning
This route is not implemented
Global Options¶
Request Tracing¶
Output Filename¶
Download From¶
Warning
This feature is not implemented