[reportlab-users] PDFPageLabels; not quite a patch yet, but getting there...

Christian Jacobsen cljacobsen at gmail.com
Tue Oct 9 04:22:22 EDT 2007


I needed to change the page numbering displayed by PDF viewers to
match the 'physical' numbering used in my generated documents (which
include roman numerals and have missing pages). This requires the use
of PDFPageLabels which, when I wrote this code at least, was not
supported by Reportlab. The attached code (which I believe I wrote
against the PDF 1.4 spec), introduces the ability to use
PDFPagelabels. More work would be required for it to become a properly
integrated part of Reportlab, as it is currently a rather low level
interface, and not what end users should really be using.

The code as it stands does work and can be used without patching a
Reportlab install, ie put the attached code in with your own files,
'from PageLabels import *', and following the example code in the
attachment should do the trick. A real patch would create some kind of
interface (possibly) in PDFgen and (possibly) somewhere in platypus,
which is easier to use than the PDFCatalogs. I haven't done this yet
as I have not been using Reportlab for long, so I'm not sure how best
to integrate this functionality. Any helpful suggestions would be

Running the attachment ('python PageLabels.py') should produce a
'output.pdf' file which will demonstrate the effect of using

Finally a technical question. Is there a way to stop PDFCatalogs and
PDFArrays from using references? The PDFPageLabels do not need to use
references and can all be specified inline (this would save some space
in the PDF, and make it easier to look at the generated output and
compare it to examples in the PDF spec). It looks to me as if there is
currently no way to specify that things should be done inline as
opposed to using references? is that correct?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PageLabels.py
Type: text/x-python-script
Size: 5426 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20071009/176ffed0/attachment.bin>

More information about the reportlab-users mailing list