如何使用ABCpdf检索自定义文档属性
本文关键字:文档 属性 自定义 检索 何使用 ABCpdf | 更新日期: 2023-09-27 18:04:03
这个页面给出了一个有用的例子,说明如何为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
谁有线索,我如何才能检索该属性?
我找到了另一种设置这些值的方法:
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");