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:12

Pimping here - my company, Atalasoft, makes .NET components for working with images. Part of the suite includes the ability to read/write PDF document metadata. It's not free, but it is run-time royalty free for desktop applications.

The code for reading is simple:

PdfDocumentMetadata metadata = PdfDocumentMetadata.FromStream(sourceStream);

to edit it and write it back to the same stream:

meta.Title = "Knicholas Knickleby";
meta.Author = "Edmund Wells";
sourceStream.Seek(0, SeekOrigin.Begin);
meta.Append(sourceStream, false); // false means don't merge - overwrite

Custom fields are supported through a hashtable.

查看更多
\"骚年 ilove
3楼-- · 2020-02-27 11:24

I suppose you can do it with iTextSharp.

查看更多
爷的心禁止访问
4楼-- · 2020-02-27 11:30

Docotic.Pdf library can be used to read and update metadata in PDF documents.

There is PdfDocument.Info property that can be used to change metadata of a PDF document (properties such as "Author", "Title").

And there is also PdfDocument.Metadata property that is useful if you need to access embedded XMP metadata in a PDF document. The library supports pre-defined XMP schemas and can also be used to set custom application-defined properties.

The library is free for non-commercial applications. (The library is no longer free since the 15th of February 2012)

Disclaimer: I work for the company.

查看更多
我只想做你的唯一
5楼-- · 2020-02-27 11:32

Aspose.PDF or Aspose.PDF.Kit can do this for you.

查看更多
女痞
6楼-- · 2020-02-27 11:33

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");
    }
  }

}

查看更多
成全新的幸福
7楼-- · 2020-02-27 11:36

Does the PdfDocumentInformation class from PDF Sharp fulfill your requirements.

查看更多
登录 后发表回答