问题
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.
So far I have looked at PDFSharp and iTextSharp
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.
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...
回答1:
See the release notes and changelog of iText 5.3.4.
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.
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.
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 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).
回答2:
We decided to go with the official Adobe PDF Library because my company is hesitant to using any free / open source software.
The library has a simple function that converts PDF to PDFA. I have confirmed the output PDF is in PDFA using the preflight tool in Adobe Acrobat Pro, thanks Bruno Lowagie for that information.
来源:https://stackoverflow.com/questions/18364258/how-to-programmaticaly-construct-pdfs-with-pdf-a-format