pdf - iTextSharp 可以将 PDF 文档转换为 PDF/A

标签 pdf itextsharp pdfa

我无法在 FAQ 中找到这个功能是否存在于 API 中,尽管它在书中提到作为潜在可用的东西。有没有人有任何实现此功能的经验?

最佳答案

This thread (日期为 2007 年 6 月)Paulo Soares 提供了显示对 PDF/A 支持的代码。这是 C# 代码(他还有一个 Java 示例):

private void PdfATest() {
    Document doc = new Document(PageSize.A4);
    PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream("C:\\hello_A1-b_cs.pdf", FileMode.Create));
    writer.PDFXConformance = PdfWriter.PDFA1B;
    doc.Open();

    PdfDictionary outi = new PdfDictionary(PdfName.OUTPUTINTENT);
    outi.Put(PdfName.OUTPUTCONDITIONIDENTIFIER, new PdfString("sRGB IEC61966-2.1"));
    outi.Put(PdfName.INFO, new PdfString("sRGB IEC61966-2.1"));
    outi.Put(PdfName.S, PdfName.GTS_PDFA1);

    // get this file here: http://old.nabble.com/attachment/10971467/0/srgb.profile
    ICC_Profile icc = ICC_Profile.GetInstance("c:\\srgb.profile");
    PdfICCBased ib = new PdfICCBased(icc);
    ib.Remove(PdfName.ALTERNATE);
    outi.Put(PdfName.DESTOUTPUTPROFILE, writer.AddToBody(ib).IndirectReference);

    writer.ExtraCatalog.Put(PdfName.OUTPUTINTENTS, new PdfArray(outi));

    BaseFont bf = BaseFont.CreateFont("c:\\windows\\fonts\\arial.ttf", BaseFont.WINANSI, true);
    Font f = new iTextSharp.text.Font(bf, 12);
    doc.Add(new Paragraph("hello", f));

    writer.CreateXmpMetadata();

    doc.Close();
}

上面的链接包括 ICC_Profile 文件的下载。

关于pdf - iTextSharp 可以将 PDF 文档转换为 PDF/A,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2366851/

相关文章:

python - 使用 Python 的 App Engine : How to convert pdf file into different jpeg images

file - 从Vue CLI项目文件夹下载.pdf文件

itextsharp - 使用 PDF itextSharp 可以在创建 pdf 文档时将图像放在文本之上

c# - ITextSharp 签署 PDF/A 文档

java - PDF/A 已通过印前检查正确验证,但在线 pdf-tools 无法验证它

pdf - Ghostscript 不会将 PDF 转换为 PDF/A。注释问题

html - 如何强制用户刷新缓存

asp.net - 使用iTextSharp的页眉,页脚和大表

pdf - ITextSharp - PdfPCell 中的文本字段

ios - 通过 HTTP 将 PDF SDK 流式传输到 iOS