We have a task to split large PDF files at their internal bookmarks, resulting in multiple, separate PDF files.
I have successfully parsed the list of bookmarks (as directed by your SDK) and can obtain the title, text, etc.
Code: Select all
private static void ReadBookmarks(int bookmarkId, int level)
{
while (true)
{
Console.WriteLine("Title: [{0}]{1}Level: [{2}]{1}",
_pdf.GetBookMarkTitle(bookmarkId), Environment.NewLine, level);
if (_pdf.GetBookMarkChildCount(bookmarkId) > 0)
{
ReadBookmarks(_pdf.GetBookMarkFirstChildID(bookmarkId), level + 1);
}
bookmarkId = _pdf.GetBookMarkNextID(bookmarkId);
if (bookmarkId == 0) break;
}
}
I have also followed the instructions given elsewhere in the forum to parse the annotations as actions to obtain the page references.
Unfortunately, the bookmarks are not recognized as annotations (GetAnnotationCount returns 0). Because of this, that recommendation (given on several similar posts to this one) is not helpful.
It appears that you typically intend bookmarks to be accessed in your viewer. My files, however, must be handled programmatically.
Is there a method when parsing a PDF to access the destination page and location of a PDF bookmark and split the file on that location.