-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
249 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,7 @@ venv/ | |
|
||
# Possible PDF generated from testing | ||
tests/outputs/** | ||
|
||
# Documentation site | ||
site/ | ||
.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block outdated %} | ||
You're not viewing the latest version. | ||
<a href="{{ '../' ~ base_url }}"> | ||
<strong>Click here to go to latest.</strong> | ||
</a> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Routes | ||
|
||
## Chromium | ||
|
||
### Common Options | ||
|
||
## LibreOffice | ||
|
||
### Options | ||
|
||
## PDF Engines | ||
|
||
### Options | ||
|
||
## Merge | ||
|
||
## Health | ||
|
||
## Metrics | ||
|
||
The metrics endpoint is not implemented yet. | ||
|
||
# Webhooks |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
This is a Python client for interfacing with [Gotenberg](https://gotenberg.dev/), which in turn is a wrapper around | ||
powerful tools for PDF generation and creation in various ways, using a stateless API. It's a very powerful tool | ||
to generate and manipulate PDFs. | ||
|
||
## Features | ||
|
||
- HTTP/2 enabled by default | ||
- Abstract away the handling of multi-part/form-data and deal with `Path`s instead | ||
- Based on the modern [httpx](https://github.com/encode/httpx) library | ||
- Full support for type hinting and concrete return types as much as possible | ||
- Nearly full test coverage run against an actual Gotenberg server for multiple Python and PyPy versions | ||
|
||
## Examples | ||
|
||
Converting a single HTML file into a PDF: | ||
|
||
```python | ||
from gotenberg_client import GotenbergClient | ||
|
||
with GotenbergClient("http://localhost:3000") as client: | ||
with client.chromium.html_to_pdf() as route: | ||
response = route.index("my-index.html").run() | ||
Path("my-index.pdf").write_bytes(response.content) | ||
``` | ||
|
||
Converting an HTML file with additional resources into a PDF: | ||
|
||
```python | ||
from gotenberg_client import GotenbergClient | ||
|
||
with GotenbergClient("http://localhost:3000") as client: | ||
with client.chromium.html_to_pdf() as route: | ||
response = route.index("my-index.html").resource("image.png").resource("style.css").run() | ||
Path("my-index.pdf").write_bytes(response.content) | ||
``` | ||
|
||
Converting an HTML file with additional resources into a PDF/A1a format: | ||
|
||
```python | ||
from gotenberg_client import GotenbergClient | ||
from gotenberg_client.options import PdfAFormat | ||
|
||
with GotenbergClient("http://localhost:3000") as client: | ||
with client.chromium.html_to_pdf() as route: | ||
response = route.index("my-index.html").resources(["image.png", "style.css"]).pdf_format(PdfAFormat.A1a).run() | ||
Path("my-index.pdf").write_bytes(response.content) | ||
``` | ||
|
||
Converting a URL into PDF, in landscape format | ||
|
||
```python | ||
from gotenberg_client import GotenbergClient | ||
from gotenberg_client.options import PageOrientation | ||
|
||
with GotenbergClient("http://localhost:3000") as client: | ||
with client.chromium.html_to_pdf() as route: | ||
response = route.url("https://hello.world").orient(PageOrientation.Landscape).run() | ||
Path("my-world.pdf").write_bytes(response.content) | ||
``` | ||
|
||
To ensure the proper clean up of all used resources, both the client and the route(s) should be | ||
used as context manager. If for some reason you cannot, you should `.close` the client and any | ||
routes: | ||
|
||
```python | ||
from gotenberg_client import GotenbergClient | ||
|
||
try: | ||
client = GotenbergClient("http://localhost:3000") | ||
try: | ||
route = client.merge(["myfile.pdf", "otherfile.pdf"]).run() | ||
finally: | ||
route.close() | ||
finally: | ||
client.close() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
site_name: Gotenberg Client | ||
|
||
site_url: https://stumpylog.github.io/gotenberg-client/ | ||
site_author: Trenton H | ||
|
||
repo_name: stumpylog/gotenberg-client | ||
repo_url: https://github.com/stumpylog/gotenberg-client | ||
|
||
nav: | ||
- "index.md" | ||
- API: "api.md" | ||
- "architecture.md" | ||
|
||
markdown_extensions: | ||
- admonition | ||
- pymdownx.highlight: | ||
anchor_linenums: true | ||
- pymdownx.superfences: | ||
custom_fences: | ||
- name: mermaid | ||
class: mermaid | ||
format: !!python/name:pymdownx.superfences.fence_code_format | ||
- toc: | ||
permalink: true | ||
|
||
theme: | ||
name: material | ||
custom_dir: docs/.override | ||
features: | ||
- navigation.tabs | ||
- navigation.sections | ||
- navigation.top | ||
- toc.integrate | ||
- search.suggest | ||
- content.code.annotate | ||
- pymdownx.superfences | ||
- pymdownx.inlinehilite | ||
- pymdownx.snippets | ||
- footnotes | ||
font: | ||
text: Roboto | ||
code: Roboto Mono | ||
palette: | ||
# Palette toggle for light mode | ||
- media: "(prefers-color-scheme: light)" | ||
scheme: default | ||
toggle: | ||
icon: material/brightness-7 | ||
name: Switch to dark mode | ||
# Palette toggle for dark mode | ||
- media: "(prefers-color-scheme: dark)" | ||
scheme: slate | ||
toggle: | ||
icon: material/brightness-4 | ||
name: Switch to light mode | ||
|
||
plugins: | ||
- search | ||
- social | ||
|
||
extra: | ||
version: | ||
provider: mike | ||
analytics: | ||
provider: google | ||
property: G-YHHSXXB0FT | ||
consent: | ||
title: Cookie consent | ||
description: >- | ||
We use cookies to recognize your repeated visits and preferences, as well | ||
as to measure the effectiveness of our documentation and whether users | ||
find what they're searching for. With your consent, you're helping us to | ||
make our documentation better. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters