Edit Metadata of PDF File with C# [closed]

2020-02-27 10:42发布

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

7条回答
男人必须洒脱
2楼-- · 2020-02-27 11:38

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

查看更多
登录 后发表回答