我正在努力创建一个带有itextSharp的PDF / A. 我仍然使用PdfAWriter返回一个看起来不错的PDF文件,但我尝试验证文件here,出了点问题。此验证工具返回以下消息:
这是我正在使用的代码:
oWriter = PdfAWriter.GetInstance(oDoc, New FileStream(sNomeFileOut, FileMode.Create), PdfAConformanceLevel.PDF_A_1B)
oWriter.PdfVersion = PdfAWriter.VERSION_1_5
Dim pdfD As New PdfDictionary()
pdfD.Put(New PdfName("Keywords"), New PdfString("DESADV"))
pdfD.Put(New PdfName("Creator"), New PdfString("TESI eIntegration"))
pdfD.Put(New PdfName("Author"), New PdfString("TESI eIntegration"))
pdfD.Put(New PdfName("Title"), New PdfString("DESADV PDS version"))
pdfD.Put(New PdfName("Subject"), New PdfString("DESADV PDS version"))
pdfD.Put(New PdfName("pdfaid:conformance"), New PdfString("PDF/A 1B"))
pdfD.Put(New PdfName("xmp:CreateDate"), New PdfString(DateTime.Now.ToShortDateString()))
pdfD.Put(New PdfName("xmp:ModifyDate"), New PdfString(DateTime.Now.ToShortDateString()))
Dim stream As New MemoryStream
Dim xmp As New XmpWriter(stream, pdfD, PdfAConformanceLevel.PDF_A_1B)
xmp.Close()
oWriter.XmpMetadata = stream.ToArray()
oWriter.PageEvent = New PdfPageEventHandler
有人可以停下来解决这个问题吗?
答案 0 :(得分:2)
您可以让iTextSharp根据您在Document
和PDF / A一致性级别上设置的元数据自动创建XMP元数据。尝试这样的事情:
Document oDoc = new Document();
PdfWriter oWriter = PdfAWriter.GetInstance(oDoc,
new FileStream(sNomeFileOut, FileMode.Create), PdfAConformanceLevel.PDF_A_1B);
oDoc.AddTitle("Some title");
oDoc.AddSubject("Subject");
oDoc.AddKeywords("Keywords, go, here");
oDoc.AddCreator("Some app");
oDoc.AddAuthor("Author");
oWriter.CreateXmpMetadata();
oDoc.Open();
//...
就像Bruno已经评论过的那样,升级是一个好主意:自5.3.3以来,已经进行了大量的PDF / A相关更改。