Quantcast

Bookmarks are associated with wrong page after some pages got deleted

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Bookmarks are associated with wrong page after some pages got deleted

strisunshine
This post has NOT been accepted by the mailing list yet.

I tried both PdfWriter and PdfStamper:
in PdfStamper I have code below:
                    (toDelegePageNumbers will be ",!4,!5" after code execution)
                    stamper.Outlines = bookmarks;
                    reader.SelectPages("1-" + reader.NumberOfPages + toDelegePageNumbers);
                    stamper.Outlines = bookmarks;
                    stamper.Close();

And alternatively in PdfWriter I used code below:
                   foreach (int page in pageToKeep)
                  {
                       doc.NewPage();
                       w.DirectContent.AddTemplate(w.GetImportedPage(reader, page), 0, 0);
                  }
                  w.Outlines = bookmarks;
                  doc.Close();


In either scenario, bookmark originally point to Page 6 still point to Page 6 in the newly generated pdf file, which is wrong coz page 4 and 5 have been deleted, original page 6 should be new page 4 now.

Is there any way we could preserve bookmarks without doing manually shifting ? There are so many existing bookmarks, and we just need to delete two pages, it seems extra amount of work for such a simple operation.


Thank you so much !
Best,
Wenting
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bookmarks are associated with wrong page after some pages got deleted

blowagie
Please use the correct channel to post questions. See http://itextpdf.com/support

The Nabble service is not endorsed by iText Group. See also http://itextpdf.com/nabble

Your mail didn't reach anyone important at iText Group, and even less people outside iText Group.
Loading...