fix PyPDF2 3.x page copying + rename documentation

- Added explicit page copying after cloneReaderDocumentRoot() calls
- Renamed PATCH_PDFWRITER.md to PATCH_PYPDF2_PDFWRITER.md
- Prevents 327-byte empty PDFs in PyPDF2 3.x

🤖 assisted by claude
This commit is contained in:
Ernad Husremovic 2025-09-02 19:31:34 +02:00
parent c54bb1c044
commit 31702e7006
3 changed files with 68 additions and 9 deletions

View file

@ -32,6 +32,10 @@ class IrActionsReport(models.Model):
# Post-process and embed the additional files.
writer = OdooPdfFileWriter()
writer.cloneReaderDocumentRoot(reader)
# Copy all pages from the reader to the writer (required for PyPDF2 3.x)
for page_num in range(reader.getNumPages()):
page = reader.getPage(page_num)
writer.addPage(page)
for edi_document in to_embed:
# The attachements on the edi documents are only system readable
# because they don't have res_id and res_model, here we are sure that