support new pikepdf.Page object when making indirect objects (closes: #132)

This commit is contained in:
Johannes Schauer Marin Rodrigues 2022-04-07 21:55:45 +02:00
parent 3b117e674b
commit 1d52530229
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -1106,8 +1106,16 @@ class pdfdoc(object):
[initial_page, PdfName.XYZ, NullObject, NullObject, 0] [initial_page, PdfName.XYZ, NullObject, NullObject, 0]
) )
# the /OpenAction array must contain the page as an indirect object # The /OpenAction array must contain the page as an indirect object.
# This changed some time after 4.2.0 and on or before 5.0.0 and current
# versions require to use .obj or otherwise we get:
# TypeError: Can't convert ObjectHelper (or subclass) to Object
# implicitly. Use .obj to get access the underlying object.
# See https://github.com/pikepdf/pikepdf/issues/313 for details.
if self.engine == Engine.pikepdf: if self.engine == Engine.pikepdf:
if isinstance(initial_page, pikepdf.Page):
initial_page = self.writer.make_indirect(initial_page.obj)
else:
initial_page = self.writer.make_indirect(initial_page) initial_page = self.writer.make_indirect(initial_page)
if self.magnification == Magnification.fit: if self.magnification == Magnification.fit: