简体   繁体   English

如何获取 PDF 注释的作者

[英]how to get the author of a PDF annotation

Is it possible to get the author of a free text annotation using iText?是否可以使用 iText 获取自由文本注释的作者?

I have the TYPE and CONTENTS, but can see noway to get the author我有 TYPE 和 CONTENTS,但无法找到作者

Please consult ISO-32000-1 table 170 "Additional entries specific to markup annotations".请参阅 ISO-32000-1 表 170“特定于标记注释的附加条目”。 It defines a key named /T that is described as an optional text string that shall be displayed in the title bar of the annotation's pop-up window when open and active.它定义了一个名为/T的键,它被描述为一个可选的文本字符串当打开和激活时,它应显示在注释弹出窗口的标题栏中。 This entry shall identify the user who added the annotation.此条目应标识添加注释的用户。

KenS is correct in the sense that the value you seek is not available for every type of annotations, but if the author is present, you'll find it in the /T entry.从某种意义上说,KenS 是正确的,您寻求的值并非适用于所有类型的注释,但如果作者在场,您将在/T条目中找到它。

So when you have this in Adobe Acrobat:因此,当您在 Adob​​e Acrobat 中有此功能时:

在此处输入图片说明

You'll find this inside the PDF:您会在 PDF 中找到以下内容:

在此处输入图片说明

You already have the /Contents and /Type entry, now you should also look for the /T entry.您已经拥有/Contents/Type条目,现在您还应该查找/T条目。 If it is missing, the author of the annotation can not be retrieved.如果缺少,则无法检索注释的作者。

These are some examples on how to get specific keys from an annotation:这些是关于如何从注释中获取特定键的一些示例:

I'm adding these links only for the sake of completeness, I think you already know the concept:我添加这些链接只是为了完整性,我想你已经知道这个概念:

PdfDictionary annotDict = annots.getAsDict(i);
PdfName author = annotDict.getAsString(PdfName.T);

If author is null , the author can not be retrieved.如果authornull ,则无法检索该作者。

While you can specify extra keys in a dictionary, which will usually be ignored, there is no 'Author' key in an annotation or FreeText annotation in the specification.虽然您可以在字典中指定额外的键(通常会被忽略),但在规范中的注释或 FreeText 注释中没有“作者”键。

So you can't get the author of a FreeText annotation, because its not normally part of an annotation.因此,您无法获得 FreeText 注释的作者,因为它通常不是注释的一部分。

请像这样使用T键

PdfString Author = annot.GetAsString(PdfName.T);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM