0

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.

AminM
  • 329
  • 1
  • 3
  • 14

3 Answers3

2

Edit: found a similar question with a solution using iTextSharp: Can iTextSharp convert PDF document to PDF/A

If your .PDFs are not longer than 10 pages, spire.pdf would be a free library you could use, as far as i know. For larger .PDFs you need a license though.

https://www.e-iceblue.com/Tutorials/Spire.PDF/Spire.PDF-Program-Guide/Conversion/How-to-Convert-PDF-to-PDF/A-in-C-VB.NET.html

  • Thanks for your reply. actually, I am asking if there is an easy way or suggestion to handle this conversion by pure C#. BTW, the number of pages is more than 10 and I've been searching for a day and did not find a satisfying solution for that. So this is why I'm asking this question here. – AminM Feb 06 '19 at 10:29
1

Syncfusion .NET PDF library supports converting PDF to PDF/A-1b using C#. Refer the below KB for more information.

https://www.syncfusion.com/kb/9515/how-to-convert-pdf-to-pdf-a-1b-using-c-and-vb-net

The whole suite of controls is available for free (commercial applications also) through the community license program if you qualify. The community license is the full product with no limitations.

Note: I work for Syncfusion.

0

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 :)

AminM
  • 329
  • 1
  • 3
  • 14
  • Sounds a bit too easy to me, PDF/A has some requirements like embedding the fonts that you probably can't satisfy by just "marking" the document as PDF/A. Have you actually tried to validate it as PDF/A e.g. with verapdf? – Stefan Hegny Feb 06 '19 at 21:03
  • I have added the result of an online PDF validity check. :) – AminM Feb 08 '19 at 16:54
  • Glad it worked for you, but just worth noting that Telerik is not _pure c#_, and is also not _free_. So in the spirit of your questions it's maybe worth marking another answer as the correct one. – Jordan Ryder Oct 21 '19 at 17:38
  • you are right @Jordan. Although I thought `Telerik` does not support it and so, therefore, I was looking for a pure `C#` as an alternative solution. but yeah, the question (and title especially) was not clear. I've updated the question to make it more clear. Thank you for mentioning that. – AminM Nov 25 '19 at 09:46