Rank: Member
Groups: Registered
Joined: 5/9/2019(UTC) Posts: 25  Location: Sydney Thanks: 1 times Was thanked: 1 time(s) in 1 post(s)
|
Hi Support,
We use the PdfDocument.Info dictionary to store some custom data.
After calling PdfDocument.Load(..), we noticed that some documents load with the PdfDocument.Info dictionary set to null. We would have expected an empty dictionary.
Is there anyway to create a new Info dictionary in the PdfDocument when its null (as we noticed the Info property on PdfDocument is readonly)?
Regards, Richard
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
Hi, Yes it is possible Code:var myinfo = PdfTypeDictionary.Create();
var list = PdfIndirectList.FromPdfDocument(doc);
list.Add(myinfo);
doc.Trailer.SetIndirectAt("Info", list, myinfo);
Now you can use the myinfo dictionary in the same way as if it were doc.Info. When you save and then reload the document, this dictionary will be accessible through the doc.Info property. Properties such as doc.Title, doc.Author, doc.Subject, etc will also work fine. Code:doc.Save(@"e:\copy.pdf", SaveFlags.NoIncremental);
doc = PdfDocument.Load(@"e:\copy.pdf");
doc.Info //not null now;
doc.Title = "Title";
Edited by user Monday, September 30, 2019 12:36:56 AM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 5/9/2019(UTC) Posts: 25  Location: Sydney Thanks: 1 times Was thanked: 1 time(s) in 1 post(s)
|
Awesome. Thank you for the prompt reply.
|
|
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close