adding bookmarks during merge

adding bookmarks during merge

Forum member · Jan 19, 2007
I'm trying to merge a collection of image-only PDFs, and I'd like to include a named bookmark to the first page of each individual PDF in the merge. The PDFs that make up the merge aren't known until run-time (as part of a search result), so I don't know at design-time how many PDFs I'll have or how many pages are in each one. From the documentation it's not clear to me how to get the proper page number of the first page of each individual PDF and apply a named bookmark to it. Any help is appreciated. Thanks.

Re: adding bookmarks during merge

Support · Jan 19, 2007
Hello, You will have to know before hand which page number to add bookmark to after the PDF documents are merged. There is nothing within our product that will keep track of the first page of all PDF documents after they are merged. Thanks, ceTe Software Support Team

Re: adding bookmarks during merge

Forum member · Jan 23, 2007
Would you give us an example? In our case we do know the page number lo link on each pdf. How, after appending a PDF can we add a bookmark-outline to the appended pages. e.g. We do the append: document.Append(@"C:\TelDir\iD_Codes.pdf"); Now, with the other pages in the document we use: page.Elements.Add(new Bookmark("Organizational Codes", 0, 0, parentOutline)), to add a reference. How can we do this with the document just appended if we do not a page object? Q

Re: adding bookmarks during merge

Support · Jan 24, 2007
Hello Q, You can add bookmarks after merging or appending the document without any problem if you know the page numbers before hand. Following is the sample code snippet to access the page and to add bookmarks after appending. document.Pages[0].Elements.Add(new Bookmark("page1",0,0)); document.Pages[1].Elements.Add(new Bookmark("page2",0,0)); Thanks, ceTe Software Support Team.

Re: adding bookmarks during merge

Forum member · Jan 24, 2007
Hi, Q. I started this thread, and I figured out what I needed to do in my case, so maybe I can help you too. I basically used a loop to gather all the PDFs that are part of the merge, and in each iteration of the loop I created a PDFDocument object with the next PDF for the merge. I used the PDFDocument to get the number of pages of each PDF as I merged them, and stored their page lengths in an array. After all the PDFs were in the merge, I added bookmarks by using my array of pagelengths as the offsets for where the bookmark goes. I'll include a small pseudo-code sample too. LOOP image = new Merger.PdfDocument(imagestream.BaseStream)

Re: adding bookmarks during merge

Forum member · Jan 24, 2007
Sorry about that, the code sample isn't all there... dim m as Merger.MergeDocument dim image as Merger.PdfDocument dim alImagePageCounts as new ArrayList() dim bookmarkpagenum as integer = 1 LOOP image = new Merger.PdfDocument(imagestream.BaseStream) alImagePageCounts.Add(image.Pages.Count) m.Append(image) END LOOP LOOP over alImagePageCounts m.Outlines.Add("bookmarkname", new ZoomDestination(bookmarkpagenum, PageZoom.FitPage)) bookmarkpagenum += alImagePageCounts(i) END LOOP I hope that helps a little.

Re: adding bookmarks during merge

Forum member · Jan 24, 2007
I am not familiar with "imagestream.BaseStream"; however this is a more creative angle to create the table of content. I will give it a try. Thanks! Q