Skip to content

Commit

Permalink
Merge pull request #28 from cyrusv/master
Browse files Browse the repository at this point in the history
Compatible with newer PyPDF2 versions
  • Loading branch information
strichter committed Oct 28, 2014
2 parents f21bdf1 + 723f12c commit 9d65f18
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 0 additions & 1 deletion buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ eggs = ${test:eggs}

[versions]
Pillow = 2.5.1
PyPDF2 = 1.21
lxml = 3.3.5
reportlab = 3.1.8
zope.interface = 4.1.1
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ def alltests():
install_requires=[
'Pygments',
'lxml',
# XXX: PyPDF2 1.22 does not work.
'PyPDF2==1.21',
'PyPDF2>=1.21',
'reportlab>=3.0',
'setuptools',
'svg2rlg',
Expand Down
12 changes: 10 additions & 2 deletions src/z3c/rml/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# in this module.
PyPDF2 = None


class MergePostProcessor(object):

def __init__(self):
Expand All @@ -32,9 +33,16 @@ def __init__(self):
def process(self, inputFile1):
input1 = PyPDF2.PdfFileReader(inputFile1)
output = PyPDF2.PdfFileWriter()
# TODO: Do not access protected classes
output._info.getObject().update(input1.documentInfo)
output._root.getObject()[NameObject("/Outlines")] = (
output._addObject(input1.trailer["/Root"]["/Outlines"]))
if output._root:
# Backwards-compatible with PyPDF2 version 1.21
output._root.getObject()[NameObject("/Outlines")] = (
output._addObject(input1.trailer["/Root"]["/Outlines"]))
else:
# Compatible with PyPDF2 version 1.22+
output._root_object[NameObject("/Outlines")] = (
output._addObject(input1.trailer["/Root"]["/Outlines"]))
for (num, page) in enumerate(input1.pages):
if num in self.operations:
for mergeFile, mergeNumber in self.operations[num]:
Expand Down

0 comments on commit 9d65f18

Please sign in to comment.