mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-19 10:19:27 -05:00
Adds setting to Gotenberg API call for outputting the correct PDF/A format
This commit is contained in:
parent
3ccb83e49c
commit
1b2cb13a21
@ -271,6 +271,16 @@ class MailDocumentParser(DocumentParser):
|
|||||||
"paperHeight": "11.7",
|
"paperHeight": "11.7",
|
||||||
"scale": "1.0",
|
"scale": "1.0",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Set the output format of the resulting PDF
|
||||||
|
# Valid inputs: https://gotenberg.dev/docs/modules/pdf-engines#uno
|
||||||
|
if settings.OCR_OUTPUT_TYPE in {"pdfa", "pdfa-2"}:
|
||||||
|
data["pdfFormat"] = "PDF/A-2b"
|
||||||
|
elif settings.OCR_OUTPUT_TYPE == "pdfa-1":
|
||||||
|
data["pdfFormat"] = "PDF/A-1a"
|
||||||
|
elif settings.OCR_OUTPUT_TYPE == "pdfa-3":
|
||||||
|
data["pdfFormat"] = "PDF/A-3b"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
url,
|
url,
|
||||||
|
@ -95,9 +95,19 @@ class TikaDocumentParser(DocumentParser):
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
headers = {}
|
headers = {}
|
||||||
|
data = {}
|
||||||
|
|
||||||
|
# Set the output format of the resulting PDF
|
||||||
|
# Valid inputs: https://gotenberg.dev/docs/modules/pdf-engines#uno
|
||||||
|
if settings.OCR_OUTPUT_TYPE in {"pdfa", "pdfa-2"}:
|
||||||
|
data["pdfFormat"] = "PDF/A-2b"
|
||||||
|
elif settings.OCR_OUTPUT_TYPE == "pdfa-1":
|
||||||
|
data["pdfFormat"] = "PDF/A-1a"
|
||||||
|
elif settings.OCR_OUTPUT_TYPE == "pdfa-3":
|
||||||
|
data["pdfFormat"] = "PDF/A-3b"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.post(url, files=files, headers=headers)
|
response = requests.post(url, files=files, headers=headers, data=data)
|
||||||
response.raise_for_status() # ensure we notice bad responses
|
response.raise_for_status() # ensure we notice bad responses
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
raise ParseError(
|
raise ParseError(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user