PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Feb 07, 2023 5:15 pm

All times are UTC

Forum rules

Please read this before posting on this forum: Forum Rules

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Mon Oct 26, 2020 3:13 pm 

Joined: Mon Oct 26, 2020 3:00 pm
Posts: 3

when I try to generate a PDF through PDFsharp in a Unity Development Build, I get an InvalidCastException:
 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.

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.

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 11 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group