[reportlab-users] Automatically set Page Scaling and Print?

kevin kevin at booksys.com
Tue Oct 2 13:31:42 EDT 2007


Hi All,

One final note on setting the page viewing preferences. First of all
that was a nice little trick. Good job hunting that down!

The way I finally impomented it, as I didn't want to mess with the
reportlab canvas class directly was to write the methods as such:

def setViewerPreference(canvas,pref,value):
catalog = canvas._doc.Catalog
VP = getattr(catalog,'ViewerPreferences',None)
if VP is None:
from reportlab.pdfbase.pdfdoc import PDFDictionary
VP = catalog.ViewerPreferences = PDFDictionary()
VP[pref] = value

def getViewerPreference(canvas,pref):
return canvas._doc.Catalog.ViewerPreferences[pref]

def delViewerPreference(canvas,pref):
del canvas._doc.Catalog.ViewerPreferences[pref]


..................
from reportlab.pdfbase.pdfdoc import PDFName

......
setViewerPreference(canvas, 'PrintScaling',PDFName('None'))
.....

passing the canvas in to some simple functions.

Once again, thanks for all the help!

Kevin at booksys.com

reportlab-users-request at reportlab.com wrote:

> Send reportlab-users mailing list submissions to

> reportlab-users at reportlab.com

>

> To subscribe or unsubscribe via the World Wide Web, visit

> http://two.pairlist.net/mailman/listinfo/reportlab-users

> or, via email, send a message with subject or body 'help' to

> reportlab-users-request at reportlab.com

>

> You can reach the person managing the list at

> reportlab-users-owner at reportlab.com

>

> When replying, please edit your Subject line so it is more specific

> than "Re: Contents of reportlab-users digest..."

>

>

> Today's Topics:

>

> 1. Re: Problem on Mac OSX (Y Tu)

> 2. Re: Problem on Mac OSX (Reed O'Brien)

> 3. Re: Problem on Mac OSX (Andy Robinson)

>

>

> ----------------------------------------------------------------------

>

> Message: 1

> Date: Tue, 2 Oct 2007 07:50:50 -0500

> From: Y Tu <ytu888 at hotmail.com>

> Subject: Re: [reportlab-users] Problem on Mac OSX

> To: Support list for users of Reportlab software

> <reportlab-users at reportlab.com>

> Message-ID: <BAY119-W2851E7A3FDB0F64E35B94F8FAE0 at phx.gbl>

> Content-Type: text/plain; charset="iso-8859-1"

>

>

> Reed

> Sorry, I got confused about the code, especially the first part. Could you explain it a bit? Thank you very much.

>

>

>> From: reed.l.obrien at nasa.gov

>> Date: Mon, 1 Oct 2007 15:57:12 -0400

>> To: reportlab-users at reportlab.com

>> Subject: Re: [reportlab-users] Problem on Mac OSX

>>

>> On Oct 1, 2007, at 3:44 PM, Andy Robinson wrote:

>>

>>

>>> I think this is a problem with the specific copy of the Python Imaging

>>> Library you have installed on your Mac OS. On many platforms, PIL is

>>> compiled with jpeg support. It seems your PIL isn't. We also had

>>> this from a customer on Mac OS last week.

>>>

>>> Can anyone who knows Mac OS well recommend what versions of PIL to

>>> install, or what options are needed to recompile it with JPEG support?

>>>

>>> On your second question, we don't normally run scripts from within an

>>> interactive prompt.

>>> If you want to, you need to run the same code which is at the bottom

>>> of that script e.g.

>>> CEO/Chief Architect

>>> ReportLab Europe Ltd.

>>> 165 The Broadway, Wimbledon, London SW19 1NE, UK

>>> Tel +44-20-8544-8049

>>> _______________________________________________

>>> reportlab-users mailing list

>>> reportlab-users at reportlab.com

>>> http://two.pairlist.net/mailman/listinfo/reportlab-users

>>>

>> cd jpeg-6b

>> ./configure # if 64 bit uncomment => CFLAGS='-fPIC'

>> make

>> make install

>> ranlib libjpeg.a

>> cp libjpeg.a /usr/local/lib

>> cp *.h /usr/local/include

>>

>> PYTHON_COMMAND="/path/to/your/python"

>>

>> cd Imaging-1.1.6

>> mv setup.py setup.py.tmp

>> SED_CMD="s|JPEG_ROOT = None|JPEG_ROOT = libinclude(\"/usr/local/lib

>> \")|; s|ZLIB_ROOT = None|ZLIB_ROOT = libinclude(\"/usr/local/lib\")|;"

>> cat setup.py.tmp | sed -e "$SED_CMD" > setup.py

>> $PYTHON_COMMAND setup.py build_ext -i

>> $PYTHON_COMMAND selftest.py

>> $PYTHON_COMMAND setup.py install

>>

>> Is what I have in my build notes.

>>

>> ~r

>> _______________________________________________

>> reportlab-users mailing list

>> reportlab-users at reportlab.com

>> http://two.pairlist.net/mailman/listinfo/reportlab-users

>>

>

> _________________________________________________________________

> Boo!?Scare away worms, viruses and so much more! Try Windows Live OneCare!

> http://onecare.live.com/standard/en-us/purchase/trial.aspx?s_cid=wl_hotmailnews

> -------------- next part --------------

> An HTML attachment was scrubbed...

> URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20071002/e0373bd2/attachment-0001.html>

>

> ------------------------------

>

> Message: 2

> Date: Tue, 2 Oct 2007 09:07:18 -0400

> From: Reed O'Brien <reed.l.obrien at nasa.gov>

> Subject: Re: [reportlab-users] Problem on Mac OSX

> To: Support list for users of Reportlab software

> <reportlab-users at reportlab.com>

> Message-ID: <6494B949-15DC-49E9-B998-089B2F1C573D at nasa.gov>

> Content-Type: text/plain; charset="us-ascii"; Format="flowed";

> DelSp="yes"

>

> #download and untar the jpeg library

> #see here for location http://www.ijg.org/

> curl http://path/to/jpegsrc.v6b.tar.gz | tar zxf -

>

> #change directory to

> cd jpeg-6b

>

> #run configure

> ./configure CFLAGS='-fPIC'

> # PIC should be fine even not on 64bit I think

>

> #run make

> make

>

> #Run make install

> sudo make install

>

> #run ranlib

> ranlib libjpeg.a

>

> #copy the lib file to lib

> cp libjpeg.a /usr/local/lib

>

> #copy headers to include

> cp *.h /usr/local/include

>

> #make this your real python

> PYTHON_COMMAND="/path/to/your/python"

>

> #get and untar the PIL source

> curl http://path/to/Imaging-1.1.6.tar.gz | tar zxf -

>

> # cd

> cd Imaging-1.1.6

>

> # copy setup out of it's way

> mv setup.py setup.py.tmp

>

> # set up a replacement command

> # you can do edit setup.py by hand if you wish

> SED_CMD="s|JPEG_ROOT = None|JPEG_ROOT = libinclude(\"/usr/local/lib

> \")|; s|ZLIB_ROOT = None|ZLIB_ROOT = libinclude(\"/usr/local/lib\")|;"

>

> #replace the stock jpg locations with the new ones you made

> cat setup.py.tmp | sed -e "$SED_CMD" > setup.py

>

> #build it

> $PYTHON_COMMAND setup.py build_ext -i

>

> #test it

> $PYTHON_COMMAND selftest.py

>

> #installit

> sudo $PYTHON_COMMAND setup.py install

>

> Is what I have in my build notes.

>

> ~r

>

> On Oct 2, 2007, at 8:50 AM, Y Tu wrote:

>

>

>> Reed

>> Sorry, I got confused about the code, especially the first part.

>> Could you explain it a bit? Thank you very much.

>>

>>

>>> From: reed.l.obrien at nasa.gov

>>> Date: Mon, 1 Oct 2007 15:57:12 -0400

>>> To: reportlab-users at reportlab.com

>>> Subject: Re: [reportlab-users] Problem on Mac OSX

>>>

>>> On Oct 1, 2007, at 3:44 PM, Andy Robinson wrote:

>>>

>>>

>>>> I think this is a problem with the specific copy of the Python

>>>>

>> Imaging

>>

>>>> Library you have installed on your Mac OS. On many platforms,

>>>>

>> PIL is

>>

>>>> compiled with jpeg support. It seems your PIL isn't. We also had

>>>> this from a customer on Mac OS last week.

>>>>

>>>> Can anyone who knows Mac OS well recommend what versions of PIL to

>>>> install, or what options are needed to recompile it with JPEG

>>>>

>> support?

>>

>>>> On your second question, we don't normally run scripts from

>>>>

>> within an

>>

>>>> interactive prompt.

>>>> If you want to, you need to run the same code which is at the

>>>>

>> bottom

>>

>>>> of that script e.g.

>>>> CEO/Chief Architect

>>>> ReportLab Europe Ltd.

>>>> 165 The Broadway, Wimbledon, London SW19 1NE, UK

>>>> Tel +44-20-8544-8049

>>>> _______________________________________________

>>>> reportlab-users mailing list

>>>> reportlab-users at reportlab.com

>>>> http://two.pairlist.net/mailman/listinfo/reportlab-users

>>>>

>>> cd jpeg-6b

>>> ./configure # if 64 bit uncomment => CFLAGS='-fPIC'

>>> make

>>> make install

>>> ranlib libjpeg.a

>>> cp libjpeg.a /usr/local/lib

>>> cp *.h /usr/local/include

>>>

>>> PYTHON_COMMAND="/path/to/your/python"

>>>

>>> cd Imaging-1.1.6

>>> mv setup.py setup.py.tmp

>>> SED_CMD="s|JPEG_ROOT = None|JPEG_ROOT = libinclude(\"/usr/local/lib

>>> \")|; s|ZLIB_ROOT = None|ZLIB_ROOT = libinclude(\"/usr/local/lib

>>>

>> \")|;"

>>

>>> cat setup.py.tmp | sed -e "$SED_CMD" > setup.py

>>> $PYTHON_COMMAND setup.py build_ext -i

>>> $PYTHON_COMMAND selftest.py

>>> $PYTHON_COMMAND setup.py install

>>>

>>> Is what I have in my build notes.

>>>

>>> ~r

>>> _______________________________________________

>>> reportlab-users mailing list

>>> reportlab-users at reportlab.com

>>> http://two.pairlist.net/mailman/listinfo/reportlab-users

>>>

>> Boo! Scare away worms, viruses and so much more! Try Windows Live

>> OneCare! Try now!

>> _______________________________________________

>> reportlab-users mailing list

>> reportlab-users at reportlab.com

>> http://two.pairlist.net/mailman/listinfo/reportlab-users

>>

>

> -------------- next part --------------

> An HTML attachment was scrubbed...

> URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20071002/67739c1c/attachment.html>

>

> ------------------------------

>

> Message: 3

> Date: Tue, 2 Oct 2007 13:56:14 +0100

> From: "Andy Robinson" <andy at reportlab.com>

> Subject: Re: [reportlab-users] Problem on Mac OSX

> To: "Support list for users of Reportlab software"

> <reportlab-users at reportlab.com>

> Message-ID:

> <956003ae0710020556o5425591er88d7d8c45a97bef8 at mail.gmail.com>

> Content-Type: text/plain; charset=UTF-8

>

> On 02/10/2007, Y Tu <ytu888 at hotmail.com> wrote:

>

>> Thank you very much, Andy. Following your instruction, I made the test

>> script running under the Python prompt. It generated the same error.

>>

>

> Yes, I would expect that. I am not sure why you wanted to run it

> under a prompt as well as a script - the result should be the same.

>

> - Andy

>

>

> ------------------------------

>

> _______________________________________________

> reportlab-users mailing list

> reportlab-users at reportlab.com

> http://two.pairlist.net/mailman/listinfo/reportlab-users

>

>

> End of reportlab-users Digest, Vol 39, Issue 5

> **********************************************

>




More information about the reportlab-users mailing list