2013-03-15 36 views
1

This page给出了一个有用的示例,说明如何为PDF设置自定义文档属性。如何使用ABCpdf检索自定义文档属性?

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

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

我找到了另一种方式来设置这些值:

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"); 
相关问题