Best way to do a table of contents?
One feature of our app lets our customers bundle multiple pdfs into one big pdf output. When we speced out the feature, they wanted a table of contents in the front with bookmarks to each of the sub documents in the whole.
I found a way to do it, but it's pretty high overhead. Because we don't have a sense in advance of how many things might be in the package and how long the Table of Contents will be (in terms of pages), I do a
and drop a bookmark with every TK.CopyForm(); (keeping track of the number of pages added in each CopyForm). Then I close that pass and get the results with a TK.BinaryImage();
Then I open a new OpenOutputFile("MEMORY"), write my table of contents with the information I collected in the first pass. Then I
TK.InputByteArray = _firstPass;
to tack on the whole result, so there's a lot of shuffling around.
Is there a best practice to make that kind of leading table of contents type thing more efficient?
Thanks for the response, James.
I was adding the bookmarks, but previously we'd been generating our own title page independent of the bookmark manager and that required me to work up the whole body with CopyForm(), close it, get the bytes, generate the title page, then CopyForm() the original body on the end, which was pretty expensive.
I'll look into using the bookmark manager and the options it provides.
Or I can try to talk our PM into just accepting that bookmarks are on the bookmark tab (without page numbers and a lot of dress up).
Please sign in to leave a comment.