mirror of
https://github.com/bringout/oca-edi.git
synced 2026-04-20 15:12:09 +02:00
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:
parent
1b3653d8fd
commit
dec5981eb0
3 changed files with 70 additions and 8 deletions
|
|
@ -41,6 +41,10 @@ class PDFHelper(models.AbstractModel):
|
|||
reader = OdooPdfFileReader(reader_buffer, strict=False)
|
||||
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)
|
||||
writer.addAttachment(xml_filename, xml_string, subtype="text/xml")
|
||||
# show attachments when opening PDF
|
||||
writer._root_object.update(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue