|
Although I didn’t figure out why I
couldn’t use PdfOutline, I found that I could use SimpleBookmark to
retrieve the bookmarks. So I found the desired bookmark, get the “Named”
key from the bookmark (map), and then I create the PdfAction as follows: PdfAction action =
"" false); stamp.setPageAction(PdfWriter.PAGE_OPEN,
action, 1); The document does get opened at the right
bookmark. But I don’t understand why the 2nd parameter of PdfAction.gotoLocalPage()
should be false. I thought it should be true but it didn’t work. Now I have another question: I’d like
to expand the bookmark tree up to the desired bookmark. How can I do that? I called
stamp.setViewerPreferences(PdfWriter.PageModeUseOutlines); so the outline is
displayed, but the tree is not expanded the way I desire. Do I have to reconstruct the PdfOutline
list? Thank you very much for any help. Joan From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of I need open a PDF document at a specified bookmark. I tried
to use PdfStamper, find the bookmark by the title, and then call
setOpenAction() to open the doc at the destination of that bookmark. However, the bookmarks seem to be null, so I couldn’t
even find the right bookmark. The code snippet is as follows: PdfReader reader = new PdfReader(fileName); PdfStamper stamp = new PdfStamper(reader, baosPDF);
PdfOutline root =
stamp.getWriter().getDirectContent().getRootOutline(); The object root from above is null. I also tried
stamp.getWriter().getRootOutline() but it’s the same result. The java doc of PdfStamper says it keeps the bookmarks of
the original document. Where am I doing something wrong? Please help. Thanks. Joan |
