PDFsharp & MigraDoc Foundation http://forum.pdfsharp.de/ |
|
Attempting to add /PieceInfo to each page of existing PDFs. http://forum.pdfsharp.de/viewtopic.php?f=2&t=4533 |
Page 1 of 1 |
Author: | WFR [ Wed Jan 10, 2024 5:13 pm ] |
Post subject: | Attempting to add /PieceInfo to each page of existing PDFs. |
I am attempting to add /PieceInfo to each page of existing PDFs. With type PdfString for Value parenthesis () wraps the value that ends up in the new Pdf. I am attempting to add /PieceInfo to each page of existing PDFs. With type PdfString for Value parenthesis () wraps the value that ends up in the new Pdf. And \before and after the existing () are added. What type and syntax is needed? Looking to add this: /PieceInfo<</Default<</LastModified(D:20231212073902-05'00')/Private<</DocID(122996605)>>>>>>" Getting this: /PieceInfo(<</Default<</LastModified\(D:20231212073902-05'00'\)/Private<</DocID\(122996605\)>>>>>>) PdfLiteral also does not work because it wraps the Value with []. The code: PdfDocument PDFDoc = PdfReader.Open(input, PdfDocumentOpenMode.Import); PdfDocument PDFNewDoc = new PdfDocument(); PdfPage pp = PDFNewDoc.AddPage(PDFDoc.Pages[Pg]); PdfString ps = new PdfString("<</Default<</LastModified(D:20231212073902-05'00')/Private<</DocID(122996605)>>>>>>"); pp.Elements.Add("/PieceInfo", ps); PDFNewDoc.Save(output); Thanks. |
Author: | (void) [ Tue Jan 16, 2024 8:52 pm ] |
Post subject: | Re: Attempting to add /PieceInfo to each page of existing PD |
I'd suggest creating the dictionary properly and not trying to "fake" it with strings or literals. e.g. Code: var doc = new PdfDocument();
var page = doc.AddPage(); var privateDict = new PdfDictionary(); privateDict.Elements.Add("/DocID", new PdfString("122996605")); var defaultDict = new PdfDictionary(); defaultDict.Elements.Add("/LastModified", new PdfString("D:20231212073902-05'00'")); defaultDict.Elements.Add("/Private", privateDict); var infoDict = new PdfDictionary(); infoDict.Elements.Add("/Default", defaultDict); page.Elements.Add("/PieceInfo", infoDict); doc.Save("out.pdf"); |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |