有没有办法使用纯 C# 将 PDF 转换为 PDF/A(如果 Telerik 不支持)

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

我正在开发一个项目,在 asp.net MVC 上运行,它使用 Telerik Report designer 创建 PDF 报告。现在我正在寻找一种创建 PDF/A (可能是版本 3)的方法,因为 Telerik 还不支持这种格式。 我知道有些图书馆支持这种格式。但是,我正在寻找一种解决方案,使用纯 C#(and/or 脚本)或免费的可信任库。

提前致谢。

编辑:使用 iTextSharp 找到了类似问题的解决方案: Can iTextSharp convert PDF document to PDF/A

如果您的 .PDF 不超过 10 页,spire.pdf 将是您可以使用的免费图书馆,据我所知。不过,对于更大的 .PDF,您需要许可证。

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

我找到了使用 Telerik 的解决方案,我想分享它,也许它对其他人有用。 我只需要将 fileObject 转换为流,然后使用这些行,我就可以在我的流上应用设置(例如 PDF/A)。 这是代码:

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;
        } 

"PDF VALIDATOR ONLINE TOOL"的结果:

checking the pdfa validity

祝你好运:)

Syncfusion .NET PDF library 支持使用 C# 将 PDF 转换为 PDF/A-1b。有关详细信息,请参阅以下知识库文章。

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

如果您符合条件,可通过 community license 计划免费获得整套控件(也可用于商业应用程序)。社区许可证是没有限制的完整产品。

注意:我为 Syncfusion 工作。