mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-01-06 09:11:38 +01:00
64 lines
2.7 KiB
Diff
64 lines
2.7 KiB
Diff
Fix for https://github.com/pdfarranger/pdfarranger/issues/716
|
|
|
|
Taken from https://github.com/pdfarranger/pdfarranger/commit/6a53d54c7f3e19ca066ea7382f843ad093c80f15https://github.com/pdfarranger/pdfarranger/issues/716
|
|
|
|
From 6a53d54c7f3e19ca066ea7382f843ad093c80f15 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Robert?= <jeromerobert@gmx.com>
|
|
Date: Sat, 17 Sep 2022 19:42:02 +0200
|
|
Subject: [PATCH] Fix NotImplementedError with PikePDF 6
|
|
|
|
Fix #716
|
|
---
|
|
pdfarranger/exporter.py | 17 ++++++++++++-----
|
|
setup.py | 2 +-
|
|
2 files changed, 13 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/pdfarranger/exporter.py b/pdfarranger/exporter.py
|
|
index ff97ac19..6e275b79 100644
|
|
--- a/pdfarranger/exporter.py
|
|
+++ b/pdfarranger/exporter.py
|
|
@@ -215,9 +215,12 @@ def _copy_n_transform(pdf_input, pdf_output, pages, quit_flag=None):
|
|
# if the page already exists in the output PDF, duplicate it
|
|
new_page = copied_pages.get((row.nfile, row.npage))
|
|
if new_page is None:
|
|
- # for backward compatibility with old pikepdf. With pikepdf > 3
|
|
- # new_page = current_page should be enough
|
|
- new_page = pdf_output.copy_foreign(current_page)
|
|
+ try:
|
|
+ # for backward compatibility with pikepdf <= 3
|
|
+ new_page = pdf_output.copy_foreign(current_page)
|
|
+ except NotImplementedError:
|
|
+ # This is pikepdf >= 6
|
|
+ new_page = current_page
|
|
# let pdf_output adopt new_page
|
|
pdf_output.pages.append(new_page)
|
|
new_page = pdf_output.pages[-1]
|
|
@@ -253,8 +256,12 @@ def export_doc(pdf_input, pages, mdata, exportmode, file_out, quit_flag):
|
|
return
|
|
outpdf = pikepdf.Pdf.new()
|
|
_set_meta(mdata, pdf_input, outpdf)
|
|
- # needed to add this, probably related to pikepdf < 2.7.0 workaround
|
|
- page = outpdf.copy_foreign(page)
|
|
+ try:
|
|
+ # needed to add this, probably related to pikepdf < 2.7.0 workaround
|
|
+ page = outpdf.copy_foreign(page)
|
|
+ except NotImplementedError:
|
|
+ # This is pikepdf >= 6
|
|
+ pass
|
|
# works without make_indirect as already applied to this page
|
|
outpdf.pages.append(page)
|
|
outname = file_out
|
|
diff --git a/setup.py b/setup.py
|
|
index 56e461ed..82c5c42f 100755
|
|
--- a/setup.py
|
|
+++ b/setup.py
|
|
@@ -51,7 +51,7 @@
|
|
entry_points={
|
|
'console_scripts': ['pdfarranger=pdfarranger.pdfarranger:main']
|
|
},
|
|
- install_requires=['pikepdf>=1.17.0,<6','python-dateutil>=2.4.0'],
|
|
+ install_requires=['pikepdf>=1.17.0','python-dateutil>=2.4.0'],
|
|
extras_require={
|
|
'image': ['img2pdf>=0.3.4'],
|
|
},
|