views:

1467

answers:

5

Hello, 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

A: 

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

Regards

crauscher
Thank you for information but i search a not commercial solution
subprime
+1  A: 

Does the PdfDocumentInformation class from PDF Sharp fulfill your requirements.

crauscher
Can you explain me how it works @crauscher
subprime
http://www.pdfsharp.net/wiki/HelloWorld-sample.ashx shows hot to create a PdfDocument and how to change the PdfDocumentInformation (PdfDocument.Info). If you want to open an existing Pdf you can use toe PfdReader class froom PDF sharp
crauscher
Can i remove/add xmp code to pdf ? Thanks for sample !
subprime
+2  A: 

I suppose you can do it with iTextSharp.

Carles
Yes, with Info property you have access to the PDF Metadata and with the Metadata property you have access to the XML metadata (XMP format)
Marc Climent
A: 

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.

plinth
+2  A: 

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

}

crauscher
i have try it but producer can not changed :( its bad VS2008 says it is read only
subprime
Due to the reason that the software is open source you can modify it. So if you want to change the producer of the document you have to modify the PdfDocument.PrepareForSave() method. It uses the producer of the original document if the document is not created using PDFSharp. Change the Producer Property of PdfDocumentInformation to be settable and modify the PrepareForSave() method. This will do it.
crauscher