i searching for methods or libarys to edit metadata of a pdf file like the programm becypdfmetaedit.
I want to write a program and i need this opton in this program. Perhaps you have some samples for c#.
Thanks
Choose File > Properties, click the Description tab, and then click Additional Metadata. Select Advanced from the list on the left. To edit the metadata, do any of the following, and then click OK. To add previously saved information, click Append, select an XMP or FFO file, and click Open.
Using PDF Sharp works like this:
using System;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main (string[] args)
{
Program p = new Program();
p.Test();
}
public void Test ()
{
PdfDocument document = PdfReader.Open ("Test.pdf");
document.Info.Author = "ME";
document.Save ("Result");
}
}
}
For PDFSharp: If you would like to change/add the metadata on the Custom Properties of a PDF you can use the PdfDocument.Info.Elements object.
String filename = @"d:\temp\Hugo-input.pdf";
String outputfile = @"d:\temp\Hugo-output.pdf";
PdfDocument document = PdfReader.Open(filename);
document.Info.Elements.Add(new KeyValuePair<String,PdfItem>("/MyKey",new PdfString("MyValue")));
document.Save(outputfile);
Always start a custom key with a slash!
You can find the key and value when you open this document in Adobe Acrobat Reader -> File -> Properties -> Custom.
This works with PDFSharp 1.32
I suppose you can do it with iTextSharp.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With