I've got an InvalidCastException in Aspose.Pdf.Kit.dll assembly with a multi-levels bookmarked Pdf. Then i tried with another Pdf (single level bookmark) and it runs without any exception.
But not with my first post that i had not sent to you because of the document privacy.
I have found out the problem. It seems your bookmark extractor engine don't support "named destinations" (PDF 1.2 feature). That's why it throws an InvalidCastException trying to cast a Named Destination as a Page Destination.
I hope this feature would be added in earlier Aspose.Pdf.Kit versions.
I am not sure about this issue, kindly if you can send me your pdf document and let me check this issue, so i can discuss this with the developer and will ask if we can support this feature in new version as well. if the size is big, then just split it and then send us that document that can reproduce this error.
I've found a PDF that throw the same System.InvalidCastException :
at x22bcffa34b42a390.x93baed8933778e80.x41b1a34077c4ae7a(x5bdee61ea12b1569 xc cb63ca5f63dc470, Int32 x66bbd7ed8c65740d, IList x9961d01c6815ef17, BookMarks xf6 9c6c8125cda4f8) at x22bcffa34b42a390.x93baed8933778e80.x2f1891c297bf7100() at Aspose.Pdf.Kit.PdfContentEditor.ExtractBookMarks()
I am able to reproduce this error with the Pdf file you have mentioned and logged it as issue # PDFKITNET-3921. I will discuss this with the developer and we will let you know as soon as solution is found.
I have checked the error, The problem is as you say, Now the bookmark extractor engine don't support "named destinations" . That's why it throws an InvalidCastException trying to cast a Named Destination as a Page Destination.
We have planed to improve the performance and reduce the memory but I am afraid we can’t finish this task in short time. Sorry for the inconvenience.
java.lang.ClassCastException: com.aspose.pdf.kit.cu cannot be cast to com.aspose.pdf.kit.ft at com.aspose.pdf.kit.k3.a(Unknown Source) at com.aspose.pdf.kit.k3.a(Unknown Source) at com.aspose.pdf.kit.k3.do(Unknown Source) at com.aspose.pdf.kit.PdfBookMarkEditor.extractBookMarks(Unknown Source) at samples.contentEditor.ExtractBookMarks.main(ExtractBookMarks.java:23)
I have reproduced the problem at my end and logged it as PDFKITJAVA-9639 in our issue tracking system. Our team will be looking into the matter and you'll be updated as the issue is resolved.