Read Document Info

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v5)  /  Re: Read Document Info

DynamicPDF CoreSuite for .NET (v5) Forum

 Jul 06 2008 10:22 PM
I have a pdf document which has some custom document information fields assigned which sit on the same level as default document properties like Author, Creator, Subject, etc. I couldnt find any method to read these custom document information fields. Can anyone help?
 Jul 07 2008 7:27 AM
Posted by a ceTe Software moderator
Hello,

You can read the Author, Creator and Subject properties of existing PDF file without any problem using our DynamicPDF Merger product. Below is the sample code for this.

   MergeDocument doc = new MergeDocument(@"Path of the PDF file");
   string strAuthor = doc.Author;
   string strCreator = doc.Creator;
   string strSubject = doc.Subject;
   doc.DrawToWeb();

What exactly you mean by reading the custom document information? How you are adding this information to the PDF? Can you please be more specific about what you are doing or adding to the PDF and how you are trying to read the information.

You can send this information to our Support Team so that they can look into it further.

Thanks,
ceTe Software Support Team.
 Jul 07 2008 8:25 PM
Thanks for the prompt reply,
We are trying to componentize pdfs by adding custom properties which sit along with the standard properties (Author, subject, etc). These fields will hold the information about the resource which needs to be included in the document, on a particular page, e.g.
Cust_Img -> C:\Images\MyImage.jpg,1,200,350
 
Cust_Img is the custom property
1 is the page number
200 is the X co-ordinate
350 is the Y co-ordinate

If I open the document containing the custom properties with Adobe Acrobat 9 Pro, I can see them on the Custom tab
I can also add new custom properties from this tab.


I can also read the custom properties using the pCOS library of PDFLib
using the following code

/* Open the input PDF */
indoc = p.open_pdi_document(inname, "");

// Get the count of all the information available from the SUMMARY tab
int count = (int)p.pcos_get_number(indoc, "length:/Info");

for (int x = 0; x < count; x++)
{
  // Get the name of the information key
  string gtmp = p.pcos_get_string(indoc, "/Info[" + x + "].key");

  // Get the value for the key which in this case is the page number
  string val = p.pcos_get_string(indoc, "/Info[" + x + "]");
}

We want to use DynamicPDF over PDFLib because of its great .Net libraries. But only this feature is holding us back as its very important for us.

 Jul 08 2008 8:23 AM
Posted by a ceTe Software moderator
Hello,

Currently it is not possible to retrieve the custom information added to the PDF document using our product.

We will add this feature to our wish list and we may add this feature to a future version but nothing is planned for now.

Thanks,
ceTe Software Support Team.
 Dec 30 2020 9:11 AM
After 12 years it is still impossible to read CustomProperties.
It's a very bizarre and questionable choice for such a simple problem to solve.
 Dec 30 2020 12:02 PM
Posted by a ceTe Software moderator
Hello,

Retrieving custom properties from an existing PDF is included in the latest release, DynamicPDF Core Suite for .NET (v11). You can download the latest version from NuGet (Package ID: ceTe.DynamicPDF.CoreSuite.NET) or from our website here.

Here is a code sample:

            //Retrieving custom properties.
            PdfDocument pdf = new PdfDocument(@"Input PDF file path");
            Dictionary<string, string> customProp = pdf.CustomProperties;
            foreach (KeyValuePair<string, string> prop in customProp)
            {
                Console.WriteLine("Key: {0}, Value: {1}", prop.Key, prop.Value);
            }

Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 6:44 AM.