[reportlab-users] ANN: pdfnup 0.3.0

Dinu Gherman gherman at darwin.in-berlin.de
Mon Dec 22 06:27:33 EST 2008


Luc Saffre:


> Dinu,

>

> thanks for you work so far! I downloaded

> http://www.dinu-gherman.net/tmp/pdfnup-0.3.3.tar.gz

> and created a file pdfnup_test.py:

>

> import sys

> from pdfnup import generateNup

> generateNup(sys.argv[1],2)

>

> This failed on a simple PDF file generated by OpenOffice:

>

> C:\temp>python pdfnup_test.py pdfnup_test.pdf

> Traceback (most recent call last):

> File "pdfnup_test.py", line 3, in <module>

> generateNup(sys.argv[1],2)

> File "s:\py-site-packages\pdfnup-0.3.3\pdfnup.py", line 284, in

> generateNup

> rotation = page2["/Rotate"].getObject()

> File "s:\py-site-packages\pyPdf-1.12\pyPdf\generic.py", line 466, in

> __getitem__

> return dict.__getitem__(self, key).getObject()

> KeyError: '/Rotate'

>

> The file I used for testing is here:

>

> http://lino.saffre-rumma.ee/dl/pdfnup_test.pdf

>

> Any idea?



Hi Luc,

sure, use the patch I've sent you on Dec, 12th via private
email. If you didn't receive it, please find it below.

Regards,

Dinu


$ diff -u pdfnup.py pdfnupX.py
--- pdfnup.py 2008-11-17 13:26:02.000000000 +0100
+++ pdfnupX.py 2008-12-19 11:02:25.000000000 +0100
@@ -281,7 +281,10 @@
page2Content.operations.insert(0, [[], "q"])

# handle rotation
- rotation = page2["/Rotate"].getObject()
+ try:
+ rotation = page2["/Rotate"].getObject()
+ except:
+ rotation = 0
if rotation in (180, 270):
dw, dh = destWidth, destHeight
arr = [-xScale, 0, 0, -yScale, destX+dw, destY+dh]


More information about the reportlab-users mailing list