Split PDF on bookmarks - get bookmark page
Posted: Mon Jun 27, 2016 4:14 pm
I am evaluating GDPicture as a potential tool to use for PDF manipulation.
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.
There is no member for the destination page, though, so I cannot identify the page numbers in order to split the file.
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.
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.