Hey,
when I try to generate a PDF through PDFsharp in a Unity Development Build, I get an InvalidCastException:
Code:
InvalidCastException: Unable to cast object of type 'PdfDictionary' to type 'PdfCatalog'.
at PdfSharp.Pdf.Advanced.PdfTrailer.get_Root () [0x00000] in <00000000000000000000000000000000>:0
at PdfSharp.Pdf.PdfDocument.get_Catalog () [0x00000] in <00000000000000000000000000000000>:0
at PdfSharp.Pdf.PdfDocument.get_Pages () [0x00000] in <00000000000000000000000000000000>:0
at PdfSharp.Pdf.PdfDocument.get_PageCount () [0x00000] in <00000000000000000000000000000000>:0
When I do the same thing in Play mode in the Unity Editor, it works just fine.
This always happens when importing an editable PDF file (with fields) and getting the first page out of it.
Code:
PdfDocument _importedBgPDF = PdfReader.Open(streamingAssetsPath + "pdf_cover_bg_INTERAKTIV.pdf", PdfDocumentOpenMode.Import);
PdfPage _importedBGPage = _importedBgPDF.Pages[0]; // error happens whenever I try to access the Pages enumerable (also when I call _importedBGPage.PageCount)
I'm using Unity 2019.4.10f1, Windows Plattform, IL2CPP and .NET 4.x.
Thanks for your help, in advance.