[reportlab-users] Automatically set Page Scaling and Print?
Robin Becker
robin at reportlab.com
Mon Oct 1 13:18:03 EDT 2007
kevin wrote:
> Hi all,
>
> We use reportlab to generate printing labels and barcode lists. At the
> moment we are fervently telling people to turn off "Page Scaling" (to
> None) before printing their documents.
>
> Is there a way that this could be set up automatically while generating
> the reportlab document? I have seen PDF documents that do this. For
> instance,
> http://www.outback.com/pressroom/pdf/restaurantnews_march2005.pdf shows
> that the Page Scaling can be turned off on the Print dialog.
>
> Any help is greatly appreciated.
>
> Thanks,
>
> Kevin at booksys.com
.......
well it didn't turn out too hard. I added this at the end of canvas
def setViewerPreference(self,pref,value):
'''set one of the allowed entries in the documents viewer preferences'''
catalog = self._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(self,pref):
'''you'll get an error here if none have been set'''
return self._doc.Catalog.ViewerPreferences[pref]
def delViewerPreference(self,pref):
'''you'll get an error here if none have been set'''
del self._doc.Catalog.ViewerPreferences[pref]
The we can use the PrintScaling entry like
canvas.setViewerPreference('PrintScaling',PDFName('None'))
It seems all the entries in ViewerPreferences are names so perhaps we can agree
to eliminate the callers use of PDFName.
--
Robin Becker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rl_hello.py
Type: text/x-python-script
Size: 338 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20071001/27c30bd4/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rl_hello.pdf
Type: application/pdf
Size: 2156 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20071001/27c30bd4/attachment-0001.pdf>
More information about the reportlab-users
mailing list