Skip to content

Commit

Permalink
Test out sending all the options for PDF/A format, see if it works on…
Browse files Browse the repository at this point in the history
… edge
  • Loading branch information
stumpylog committed Dec 4, 2023
1 parent 5da99c4 commit 52426e9
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated how pytest is configured, so it will apply to any invocation
- Updated test running image to log at warning or lower using text format
- Updated test running image from 7.9.2 to 7.10.1
- For the moment, send both `pdfa` and `pdfFormat` for compatibility with 7.9 and 7.10
- See [here](https://github.com/stumpylog/gotenberg-client/issues/5#issuecomment-1839081129) for some subtle differences in what these options mean

### Added

Expand Down
6 changes: 5 additions & 1 deletion src/gotenberg_client/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from httpx import Response
from httpx._types import RequestFiles

from gotenberg_client._types_compat import Self
from gotenberg_client._typing_compat import Self
from gotenberg_client._utils import guess_mime_type
from gotenberg_client.options import PdfAFormat

Expand Down Expand Up @@ -114,6 +114,10 @@ def pdf_format(self, pdf_format: PdfAFormat) -> Self:
self._form_data.update(pdf_format.to_form())
return self

def universal_access_pdf(self, *, pdf_ua: bool) -> Self:
self._form_data.update({"pdfua": str(pdf_ua).lower()})
return self

def trace(self, trace_id: str) -> Self:
self._headers["Gotenberg-Trace"] = trace_id
return self
Expand Down
2 changes: 1 addition & 1 deletion src/gotenberg_client/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from gotenberg_client._convert.pdfa import PdfAApi
from gotenberg_client._health import HealthCheckApi
from gotenberg_client._merge import MergeApi
from gotenberg_client._types_compat import Self
from gotenberg_client._typing_compat import Self


class GotenbergClient:
Expand Down
2 changes: 1 addition & 1 deletion src/gotenberg_client/_convert/chromium.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from gotenberg_client._base import BaseApi
from gotenberg_client._convert.common import ConvertBaseRoute
from gotenberg_client._types_compat import Self
from gotenberg_client._typing_compat import Self
from gotenberg_client.options import EmulatedMediaType
from gotenberg_client.options import Margin
from gotenberg_client.options import PageSize
Expand Down
2 changes: 1 addition & 1 deletion src/gotenberg_client/_convert/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging

from gotenberg_client._base import BaseRoute
from gotenberg_client._types_compat import Self
from gotenberg_client._typing_compat import Self
from gotenberg_client.options import PageOrientation

logger = logging.getLogger()
Expand Down
2 changes: 1 addition & 1 deletion src/gotenberg_client/_convert/libre_office.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from gotenberg_client._base import BaseApi
from gotenberg_client._convert.common import ConvertBaseRoute
from gotenberg_client._types_compat import Self
from gotenberg_client._typing_compat import Self


class LibreOfficeConvertRoute(ConvertBaseRoute):
Expand Down
2 changes: 1 addition & 1 deletion src/gotenberg_client/_convert/pdfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from gotenberg_client._base import BaseApi
from gotenberg_client._convert.common import ConvertBaseRoute
from gotenberg_client._types_compat import Self
from gotenberg_client._typing_compat import Self


class PdfAConvertRoute(ConvertBaseRoute):
Expand Down
File renamed without changes.
9 changes: 6 additions & 3 deletions src/gotenberg_client/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ class PdfAFormat(enum.Enum):
A3b = enum.auto()

def to_form(self) -> Dict[str, str]:
format_name = None
if self.value == PdfAFormat.A1a.value:
return {"pdfFormat": "PDF/A-1a"}
format_name = "PDF/A-1a"
elif self.value == PdfAFormat.A2b.value:
return {"pdfFormat": "PDF/A-2b"}
format_name = "PDF/A-2b"
elif self.value == PdfAFormat.A3b.value:
return {"pdfFormat": "PDF/A-3b"}
format_name = "PDF/A-3b"
if format_name is not None:
return {"pdfa": format_name, "pdfFormat": format_name}
else: # pragma: no cover
raise NotImplementedError(self.value)

Expand Down

0 comments on commit 52426e9

Please sign in to comment.