如何使用ABCpdf检索自定义文档属性?

时间:2013-03-15 20:29:59

标签: c# abcpdf

This page提供了有关如何为pdf设置自定义文档属性的有用示例。

所以我已经完成了这个(我已经验证了自定义属性是在文件中设置的):

Doc theDoc = new Doc();
int theID = theDoc.AddObject("<< >>");
theDoc.SetInfo(-1, "/Info:Ref", theID.ToString());
theDoc.SetInfo(theID, "/Company:Text", "ACME");
theDoc.Save(FileName);

我正在尝试稍后检索该属性。我试过了:

Doc theDoc = new Doc();
theDoc.Read(FileName);
int theID = theDoc.AddObject("<< >>");
theDoc.SetInfo(-1, "/Info:Ref", theID.ToString());
return theDoc.GetInfo(theID, "/Company:Text"); //returns empty string

//...read theDoc
int theID = theDoc.GetInfoInt(-1, "/Info");
return theDoc.GetInfo(theID, "/Company:Text"); //returns empty string

任何人都知道如何检索该属性?

1 个答案:

答案 0 :(得分:0)

我找到了设置这些值的另一种方法:

if (theDoc.GetInfo(-1, "/Info") == "")
    theDoc.SetInfo(-1, "/Info:Ref", theDoc.AddObject("<< >>").ToString());
theDoc.SetInfo(-1, "/Info*/Company:Text", "ACME");

以这种方式设置值后,我可以像这样检索它们:

if (theDoc.GetInfo(-1, "/Info") == "")
    theDoc.SetInfo(-1, "/Info:Ref", theDoc.AddObject("<< >>").ToString());
string companyName = theDoc.GetInfo(-1, "/Info*/Company:Text");