This is a migrated thread and some comments may be shown as answers.

PdfFormatProvider Export - NullReferenceException

5 Answers 349 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Jonas
Top achievements
Rank 1
Jonas asked on 02 Mar 2021, 10:59 AM

Hello, I'm trying out the DevCraft trial to do conversion from pdf to pdfa, however the .Export method throws a nullreference exception far inside the Telerik-components. Not sure how to proceed, since the error tells me nothing.

I followed the example shown here: https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/howto/comply-with-pdfa-standard

The exception thrown:

The type initializer for 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.ColorSpaces.IccProfileObject' threw an exception.
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.ColorSpaces.IccProfileObject.get_SRgbProfile()
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.OutputIntent..ctor()
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.DocumentCatalog.CopyPagePropertiesFrom(IRadFixedDocumentExportContext context)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Model.Elements.DocumentStructure.DocumentCatalog.CopyPropertiesFrom(IRadFixedDocumentExportContext context)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfExporter.Export(IRadFixedDocumentExportContext context, Stream output)
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider.ExportOverride(RadFixedDocument document, Stream output)
   at Telerik.Windows.Documents.Common.FormatProviders.FormatProviderBase`1.Export(T document, Stream output)
   at Telerik.Windows.Documents.Common.FormatProviders.BinaryFormatProviderBase`1.Export(T document)
   at PdfaConverter.Tjenester.Converters.PdfConverter.ConvertToPdfa(string base64) in E:\Repositories\PdfaConverter\PdfaConverter\Tjenester\Converters\PdfConverter.cs:line 21
   at ConsoleTest.Program.Konverter(String inputPath, String outputPath, IConverter converter, String filetype) in E:\Repositories\PdfaConverter\ConsoleTest\Program.cs:line 51
   at ConsoleTest.Program.KonverterPdfToPdfa() in E:\Repositories\PdfaConverter\ConsoleTest\Program.cs:line 24
   at ConsoleTest.Program.Main(String[] args) in E:\Repositories\PdfaConverter\ConsoleTest\Program.cs:line 17

 

My code:

public string ConvertToPdfa(string base64)
{
    PdfFormatProvider provider = new PdfFormatProvider();
    var document = provider.Import(Convert.FromBase64String(base64));
 
    PdfExportSettings settings = new PdfExportSettings();
    settings.ComplianceLevel = PdfComplianceLevel.PdfA2B;
    provider.ExportSettings = settings;
 
    return Convert.ToBase64String(provider.Export(document));
}

5 Answers, 1 is accepted

Sort by
0
Jonas
Top achievements
Rank 1
answered on 02 Mar 2021, 11:01 AM
This is a .net5.0 asp.net core application btw.
0
Accepted
Tanya
Telerik team
answered on 02 Mar 2021, 01:24 PM

Hi Jonas,

I have just replied to the support ticket you submitted about this question. Would you please provide the document you are using there so we can investigate the case? I would suggest continuing the discussion in the support ticket so we can keep the information about the case consistent. Thank you in advance for your cooperation.

Regards,
Tanya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
loe
Top achievements
Rank 1
answered on 17 Mar 2021, 10:06 AM

Hi

I am facing the same issue. Can you share any news?

Thanks!

0
Jonas
Top achievements
Rank 1
answered on 17 Mar 2021, 10:17 AM

Hey, 

This is being fixed for the next release, but to work around it I downgraded my assemblies to 118.

0
loe
Top achievements
Rank 1
answered on 17 Mar 2021, 10:21 AM
Thank you for your reply, that works for me!
Tags
PdfProcessing
Asked by
Jonas
Top achievements
Rank 1
Answers by
Jonas
Top achievements
Rank 1
Tanya
Telerik team
loe
Top achievements
Rank 1
Share this question
or