如何使用PDF / A格式编程构建PDF [英] How to programmaticaly construct PDFs with PDF/A format
问题描述
我需要编写一个.NET应用程序,它将从数据库中获取各种数据并构建一个PDF,由于公司标准,它必须是PDF / A格式。
I need to write a NET application that will take various data from databases and construct a PDF which must be in PDF/A format because of the companies standards.
到目前为止,我已经查看了PDFSharp和iTextSharp
So far I have looked at PDFSharp and iTextSharp
我在PDFSharp论坛中看到一个主题 http://forum.pdfsharp.net/viewtopic.php?p=1293#p1293 讨论这个话题,他们多年前已经说过PDF / A支持在他们的待办事项列表中,但没有任何结果。
I see a topic in PDFSharp forums http://forum.pdfsharp.net/viewtopic.php?p=1293#p1293 dicussing this very topic and they have said years ago that PDF/A support is in their todo list, but nothing came of it.
我找不到任何有关使用这些库的PDF / A格式的信息。我是否需要在满足PDF / A限制的同时构建PDF?我不知道如何验证文件是PDF / A格式......
I cannot find any information about PDF/A format using these libraries. Do I need to build the PDFs while meeting PDF/A restrictions? I do not know how to verify a file is in PDF/A format...
推荐答案
您可以创建PDF / A-1(A级/ B级),PDF / A-2和使用iTextSharp的PDF / A-3文件。但是,我们仅在PDF / A-1的创建过程中检查一致性。如果您创建PDF / A-2和PDF / A-3文件,作为开发人员,您有责任不介绍破坏PDF / A一致性的内容。在未来的版本中,iText会为您检查。
You can create PDF/A-1 (level A / level B), PDF/A-2 and PDF/A-3 files using iTextSharp. However, we only check conformance during the creation process for PDF/A-1. If you create PDF/A-2 and PDF/A-3 files, it's your responsibility as a developer not to introduce something that breaks PDF/A conformance. In future versions, iText will check that for you.
带有iText的PDF / A-3 让您了解所需内容(示例是Java中的,但将它们移植到C#应该不是问题)。确保使用 PdfAWriter
类而不是 PdfWriter
,并确保您拥有最新版本。
PDF/A-3 with iText gives you an idea of what is needed (the examples are in Java, but it shouldn't be a problem to port them to C#). Make sure you use the PdfAWriter
class instead of PdfWriter
, and make sure you have the latest version.
请注意,创建PDF / A Level A是一项挑战。您必须在代码中设置每个元素(段落
, Anchor
,...)的角色。通常,使用XFA模板,填充XFA数据,然后让iText的XFA工作人员将其展平,就容易得多。
Note that creating PDF/A Level A is a challenge. You have to set the role of every element (Paragraph
, Anchor
,...) in your code. Often it's much easier to use an XFA template, fill it with XFA data, and then have iText's XFA Worker flatten it.
iText不会对现有PDF进行验证一个文件。重要的是要知道文档顶部显示的蓝条,说文档是PDF / A,是不够的。您需要验证文档,例如使用Adobe Acrobat(预检功能)。
iText doesn't do verification of existing PDF/A files. It's important to know that the 'blue bar' shown on top of the document, saying that the document is PDF/A, isn't sufficient. You need to verify the document, for instance using Adobe Acrobat (Preflight functionality).
这篇关于如何使用PDF / A格式编程构建PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!