使用iTextSharp从PDF中提取其他元数据 [英] Extracting Additional Metadata from a PDF using iTextSharp

查看:156
本文介绍了使用iTextSharp从PDF中提取其他元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到使用iTextSharp提取基本元数据(即作者,标题),它通常看起来像这样:

I've seen the extraction of basic metadata (ie. author, title) using iTextSharp and it usually looks something like this:

var pdfReader = new PdfReader(pdfData);
var author = pdfReader.Info["author"]

但是,就我而言,我在更具异国情调的东西之后,文档可能包含额外的高级元数据。

However, in my case I'm after something a bit more exotic, the additional "advanced" metadata that the document may contain.

原谅油漆亮点,但这里是Adobe Acrobat中的截图显示有问题的数据:

Pardon the paint highlights, but here is a screenshot from within Adobe Acrobat showing the data in question:

在这种情况下,通过 Info 字典似乎无法获得此数据。使用不同的库(TallComponents的PDFKit)这个数据被公开,但我想知道是否有任何方法使用iItext获取它

In this case, it doesn't seem like this data is available through the Info dictionary. Using a different library (PDFKit by TallComponents) this data is exposed, but I'm wondering if there is any way get it using iItext

我正在玩iText 4.1.6由于许可限制,但如果增加了所需的功能,我不会反对购买5.0.6的商业许可证。

I'm currently playing with iText 4.1.6 due to licensing restrictions, but I wouldn't be opposed to buying the commercial license for 5.0.6 if that adds required functionality.

推荐答案

不确定它是否能完全满足您的需求,但要获得 XMP元数据尝试这样的事情:

not sure if it will get exactly what you need, but to get the XMP metadata try something like this:

PdfReader reader = new PdfReader(YOUR_PDF);
byte[] b = reader.Metadata;
if (b != null) {
  string xml = new UTF8Encoding().GetString(b);
}

请注意您返回 XML 字符串。

IIRC代码适用于4.1.6。

IIRC the code will work with 4.1.6.

这篇关于使用iTextSharp从PDF中提取其他元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆