Modifying PDF document properties

Thanks to both Mindaugas and Knobloch. Since you both pointed to iTextSharp I went for this and was able to solve my problem using iTextSharp and code similar to that shown below. One thing I noticed was that the resulting file was 115,143 bytes smaller, from a starting file of 3,639,172, so it looks like I'm either losing some information or this library is more efficient than the original product used to create the document.

The other interesting thing is that when reading about this library I kept seeing links to iText in Action which is published by the same publisher of the eBooks that I am having problems with:-)

        using System.Diagnostics;
        using iTextSharp.text.pdf;
        using System.IO;
        using System.Collections;

        PdfReader pdfReader = new PdfReader(filePath);
        using (FileStream fileStream = new FileStream(newFilePath, FileMode.Create, FileAccess.Write))
        {
            string title = pdfReader.Info["Title"] as string;
            Trace.WriteLine("Existing title: " + title);

            PdfStamper pdfStamper = new PdfStamper(pdfReader, fileStream);

            // The info property returns a copy of the internal HashTable
            Hashtable newInfo = pdfReader.Info;

            newInfo["Title"] = "New title";

            pdfStamper.MoreInfo = newInfo;

            pdfReader.Close();
            pdfStamper.Close();
        }

Here's a list of open-source PDF Libraries in C#

A couple of other libraries, that are not on that list:
ByteScout-PDF
iTextSharp


Have you looked at iTextSharp? It's a PDF API for .Net. You can do some fairly useful stuff with PDF's using it.

iTextSharp on Sourceforge

Tags:

.Net

Pdf