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
任何人都知道如何检索该属性?
答案 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");