diff --git a/src/paperless/parsers/mail.py b/src/paperless/parsers/mail.py index 1b96982ad..4728fe75a 100644 --- a/src/paperless/parsers/mail.py +++ b/src/paperless/parsers/mail.py @@ -566,7 +566,7 @@ class MailDocumentParser: # If no HTML content, create the PDF from the message. # Otherwise, create 2 PDFs and merge them with Gotenberg. if not mail_message.html: - archive_path.write_bytes(mail_pdf_file.read_bytes()) + shutil.copyfile(mail_pdf_file, archive_path) else: pdf_of_html_content = self.generate_pdf_from_html( mail_message.html, diff --git a/src/paperless/parsers/tesseract.py b/src/paperless/parsers/tesseract.py index 7cae31e0a..4548826c5 100644 --- a/src/paperless/parsers/tesseract.py +++ b/src/paperless/parsers/tesseract.py @@ -443,7 +443,7 @@ class RasterisedDocumentParser: self.log.warning( f"PDF/A metadata stamping failed ({e!s}); falling back to plain PDF.", ) - pdfa_path.write_bytes(plain_pdf_path.read_bytes()) + shutil.copyfile(plain_pdf_path, pdfa_path) return pdfa_path