【问题标题】:Set XMP Data with itextSharp 5.3.3使用 itextSharp 5.3.3 设置 XMP 数据
【发布时间】:2014-04-29 14:40:01
【问题描述】:

我正在努力使用 itextSharp 创建 PDF/A 我仍然使用返回看起来不错的 PDF 文件的 PdfAWriter,但我尝试验证文件 here,出现问题。此验证工具返回以下消息:

  • dc:title/*[0] :: 缺少语言限定符。
  • dc:description/*[0] :: 缺少语言限定符。
  • 缺少所需的 XMP 属性“pdfaid:part”
  • 缺少所需的 XMP 属性“pdfaid:conformance”
  • 缺少文档信息条目“CreationDate”所需的 XMP 属性“xmp:CreateDate”。
  • 缺少文档信息条目“ModDate”所需的 XMP 属性“xmp:ModifyDate”

这是我正在使用的代码:

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

有人能解决这个问题吗?

【问题讨论】:

  • 升级到 iText 5.5.0。如果您查看更改日志和发行说明,您会发现自 2012 年 9 月 22 日(即 iTextSharp 5.3.3 发布日期)以来,已添加了大量额外的 PDF/A 相关功能。

标签: pdf itextsharp xmp


【解决方案1】:

您可以让 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 相关的更改。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 2013-04-24
    • 2012-03-03
    • 1970-01-01
    相关资源
    最近更新 更多