Bookmark iteration problem
General-Purpose PDF Library for Java and .NET
Status: Beta
Brought to you by:
stechio
Hi,
I have a PDF file which has three bookmarks. Pdf clown returns only one bookmark when I iterate bookmarks.
When I looked the Bookmarks.cs's GetEnumerator method. it seems that first bookmark object must have /Next keyword but my pdf file has not.
I tried to fix that but I think that this is not the best solution.
I changed GetEnumerator method like this:
IEnumerator<Bookmark> IEnumerable<Bookmark>.GetEnumerator(
)
{
PdfDictionary firstBookmarkDictionary = BaseDataObject;
PdfDirectObject tempBookmarkObject = null;
PdfDirectObject bookmarkObject = null;
do
{
tempBookmarkObject = firstBookmarkDictionary[PdfName.First];
if (tempBookmarkObject != null)
{
bookmarkObject = tempBookmarkObject;
firstBookmarkDictionary = (PdfDictionary)bookmarkObject.Resolve();
}
} while (tempBookmarkObject != null);
if (bookmarkObject == null)
yield break;
do
{
yield return new Bookmark(bookmarkObject);
bookmarkObject = ((PdfDictionary)bookmarkObject.Resolve())[PdfName.Next];
} while (bookmarkObject != null);
}
Diff:
Your bug is not confirmed -- I tried your attachment through BookmarksParsingSample but its output seems ok: