2013-03-15 87 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"); 
相關問題