Exception when PDF/A document is saved after adding image and text


I found that method Save of Aspose.Pdf.Document throws an exception after the following actions: add image, add text, add one more image.

Demo project where the problem is shown:

System.InvalidCastException: Unable to cast object of type '  ' to type '  '.
   at   .()
   at   .(String )
   at   .      ()
   at ​ .()
   at   .      (   , Boolean )
   at   .      (   )
   at   .(   )
   at   .(   , ​  )
   at   .(   ,    , Page )
   at   .(   , Page )
   at   .(   , Page )
   at   .(Page , OperatorCollection , Resources , Int32 ,  )
   at   .(Page ,  )
   at   .()
   at   .      ()
   at   .()
   at   .      (XmlTextWriter , PdfFormat , Document , Boolean , ConvertErrorAction )
   at Aspose.Pdf.Document.(XmlTextWriter , PdfFormat , Boolean , ConvertErrorAction )
   at Aspose.Pdf.Document.Save(Stream output)
   at AsposeTest.PdfImageEditor.InsertPngImageIntoDocument(Stream document, Stream image, Int32 pageNumber, Double imageHeight, Double imageWidth, Double imageLeft, Double imageBottom, Stream& output) in C:\Tak\Projects\AsposePdfTest\InsertImageTest_ErrorTest\AsposeTest\PdfImageEditor.vb:line 47


Thanks for contacting support.

I am afraid that you are using a quite old version of the API, whereas we always recommend to use latest version of the API, which is Aspose.Pdf for .NET 17.9 now.

Nevertheless, I have tested the scenario by running your project with latest version of the API and was unable to notice the exception which you have mentioned. Though the exception was occurring while using older version of the API, but it seems that it is not reproducible with latest version, as each latest version comes with more improvements and fixes.

Furthermore, I have observed that, only one image appeared in the generated output after calling the InsertPngImageIntoDocument(...) twice and also, when I viewed resultant PDF in Adobe Reader, a Bad Font Descriptor dialog showed up. Hence, for the sake of investigation, I have logged noticed issue as PDFNET-43443 in our issue tracking system. We will further look into the details of the issue and keep you posted with the status.

For your reference, I have attached an output, generated over my end. Please be patient and spare us little time.

OutputPDFA.pdf (857.5 KB)

We are sorry for the inconvenience.