1

此页面提供了一个有用的示例,说明如何为 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

有人知道我如何检索该属性吗?

4

1 回答 1

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");
于 2013-03-22T13:08:06.153 回答