[reportlab-users] RE: Creating outlines and bookmarks from Platypus?
Dinu Gherman
reportlab-users@reportlab.com
Fri, 16 Apr 2004 08:48:21 +0200
--Apple-Mail-2-711686276
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
Marc Stober:
> Here's the class I use to create bookmarks. You're probably right that
> it
> should inherit from ActionFlowable and not just Flowable; this has
> always
> worked for me anyhow. It would have to be extended further to support
> nested
> bookmarks.
>
> class Bookmark(Flowable):
> """ Utility class to display PDF bookmark. """
>
> def __init__(self, title, key):
> self.title = title
> self.key = key
> Flowable.__init__(self)
>
> def wrap(self, availWidth, availHeight):
> """ Doesn't take up any space. """
> return (0, 0)
>
> def draw(self):
> # set the bookmark outline to show when the file's opened
> self.canv.showOutline()
> # step 1: put a bookmark on the
> self.canv.bookmarkPage(self.key)
> # step 2: put an entry in the bookmark outline
> self.canv.addOutlineEntry(self.title,
> self.key, 0, 0)
Note that if you have many such top-level entries, like 10,000 or so,
and you set self.canv.showOutline() to show the outline when the doc
is being opened, Acrobat Reader will take ages to show anything at
all. AR 6 is behaving much better than AR 5, although it still can
take a while... So, then you really need a nested outline.
Dinu
--
Dinu C. Gherman - http://python.net/~gherman
......................................................................
"Political satire became obsolete when Henry Kissinger was awarded
the Nobel Peace Prize." (Tom Lehrer)
--Apple-Mail-2-711686276
Content-Transfer-Encoding: 7bit
Content-Type: text/enriched;
charset=US-ASCII
Marc Stober:
<excerpt>Here's the class I use to create bookmarks. You're probably
right that it
should inherit from ActionFlowable and not just Flowable; this has
always
worked for me anyhow. It would have to be extended further to support
nested
bookmarks.
class Bookmark(Flowable):
""" Utility class to display PDF bookmark. """
def __init__(self, title, key):
self.title = title
self.key = key
Flowable.__init__(self)
def wrap(self, availWidth, availHeight):
""" Doesn't take up any space. """
return (0, 0)
def draw(self):
# set the bookmark outline to show when the file's opened
self.canv.showOutline()
# step 1: put a bookmark on the
self.canv.bookmarkPage(self.key)
# step 2: put an entry in the bookmark outline
self.canv.addOutlineEntry(self.title,
self.key, 0, 0)
</excerpt>
Note that if you have many such top-level entries, like 10,000 or so,
and you set self.canv.showOutline() to show the outline when the doc
is being opened, Acrobat Reader will take ages to show anything at
all. AR 6 is behaving much better than AR 5, although it still can
take a while... So, then you really need a nested outline.
Dinu
--
Dinu C. Gherman - http://python.net/~gherman
......................................................................
"Political satire became obsolete when Henry Kissinger was awarded
the Nobel Peace Prize." (Tom Lehrer)
--Apple-Mail-2-711686276--