Repair PDF before all processing

Some PDFs choke both pdfminer.six and Ghostscript but the issues can be fixed first.

Fixes #1403
This commit is contained in:
James R. Barlow
2024-10-27 17:37:46 -07:00
parent 5e478a7774
commit ee5acbe94e
+7 -2
View File
@@ -159,8 +159,13 @@ def triage(
"Argument --image-dpi is being ignored because the "
"input file is a PDF, not an image."
)
# Origin file is a pdf create a symlink with pdf extension
safe_symlink(input_file, output_file)
try:
with pikepdf.open(input_file) as pdf:
pdf.save(output_file)
except pikepdf.PdfError as e:
raise InputFileError() from e
except pikepdf.PasswordError as e:
raise EncryptedPdfError() from e
return output_file
except OSError as e:
log.debug(f"Temporary file was at: {input_file}")