Search code examples
c#asp.netpdftelerikpdfa

Is there a way to convert PDF to PDF/A using pure C# (if Telerik cannot support it)


I'm working on a project, Runs on asp.net MVC which uses Telerik Report designer to create PDF reports. Now I'm seeking for a way to create PDF/A (perhaps version 3) since Telerik does not support this format yet. I know there are some libraries they support this format. however, I'm looking for a solution to make it using pure C# (and/or scripts) or free trustable libraries.

Thanks in advance.


Solution

  • I found the solution using Telerik and I wanted to share it maybe it was useful for others. I just needed to convert the fileObject to stream and then, using these lines, I am able to apply settings (e.g. PDF/A) on my stream. here's the code:

    private Stream PdfToPdfa(Stream input)
            {
                PdfFormatProvider provider = new PdfFormatProvider();
                PdfExportSettings settings = new PdfExportSettings();
                settings.ComplianceLevel = PdfComplianceLevel.PdfA3B;
                provider.ExportSettings = settings;
                RadFixedDocument document = provider.Import(input);
    
                Stream output = new MemoryStream();
                provider.Export(document, output);
    
                return output;
            } 
    

    The result on "PDF VALIDATOR ONLINE TOOL":

    checking the pdfa validity

    Good luck :)