PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

Modify metadata without opening the PDF
http://forum.pdfsharp.de/viewtopic.php?f=2&t=1543
Page 1 of 1

Author:  Kroony [ Fri Feb 11, 2011 3:22 am ]
Post subject:  Modify metadata without opening the PDF

I need to modify the title property of a lot of pdfs automatically. I tried successfully to modify the title with the following code:
Code:
PdfDocument document =  PdfReader.Open(dest_file, PdfDocumentOpenMode.Modify);
document.Info.Title = filename;
document.Save(dest_file);


As you can see, this would open a file, modify the title of it and then save it back over itself. While the title did change, it also made all of the pages portrait. As the original files have a mixture, we ended up with all of the pages that were landscape being saved as portrait. This was made worse due to the content of the page not being rotated to fit, but only filling the top part of the page, and having the right hand side chopped off.

Is there a way to modify this metadata without opening and saving the pdf? - Ideal solution. (I believe I have seen programs that can do this, but I need to do it in bulk with a program already writen in C#.)

Failing that, can I open it without any modifications taking place to the pdf document layout and content, so I can just change the title?

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/