diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e2ff69..714ffcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/gotenberg_client/_base.py b/src/gotenberg_client/_base.py index 42aa930..bf223bf 100644 --- a/src/gotenberg_client/_base.py +++ b/src/gotenberg_client/_base.py @@ -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 @@ -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 diff --git a/src/gotenberg_client/_client.py b/src/gotenberg_client/_client.py index 9068dad..9677d20 100644 --- a/src/gotenberg_client/_client.py +++ b/src/gotenberg_client/_client.py @@ -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: diff --git a/src/gotenberg_client/_convert/chromium.py b/src/gotenberg_client/_convert/chromium.py index dfbc461..88850f0 100644 --- a/src/gotenberg_client/_convert/chromium.py +++ b/src/gotenberg_client/_convert/chromium.py @@ -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 diff --git a/src/gotenberg_client/_convert/common.py b/src/gotenberg_client/_convert/common.py index afb88fb..dac2fba 100644 --- a/src/gotenberg_client/_convert/common.py +++ b/src/gotenberg_client/_convert/common.py @@ -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() diff --git a/src/gotenberg_client/_convert/libre_office.py b/src/gotenberg_client/_convert/libre_office.py index 65654f8..29c508c 100644 --- a/src/gotenberg_client/_convert/libre_office.py +++ b/src/gotenberg_client/_convert/libre_office.py @@ -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): diff --git a/src/gotenberg_client/_convert/pdfa.py b/src/gotenberg_client/_convert/pdfa.py index d0ba3e2..cb95156 100644 --- a/src/gotenberg_client/_convert/pdfa.py +++ b/src/gotenberg_client/_convert/pdfa.py @@ -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): diff --git a/src/gotenberg_client/_types_compat.py b/src/gotenberg_client/_typing_compat.py similarity index 100% rename from src/gotenberg_client/_types_compat.py rename to src/gotenberg_client/_typing_compat.py diff --git a/src/gotenberg_client/options.py b/src/gotenberg_client/options.py index 4751de7..d2ef4ae 100644 --- a/src/gotenberg_client/options.py +++ b/src/gotenberg_client/options.py @@ -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)