Reading Custom Properties in the PDF.Info section

Hi there, I can use your PDF Library to put Data into Custom properties easily enough. However I don’t Seem to be able to Read custom values. Is there some trick to this?

Hi Kieran,

Try this:

using (var document = PdfDocument.Load("input.pdf"))
{
    var infoDictionary = document.Info.GetOrAddDictionary();
    if (infoDictionary.TryGetValue(PdfName.Create("My Custom Property"), out PdfBasicObject value))
    {
        Console.WriteLine(value.ObjectType);
        Console.WriteLine(value.ToString());
    }
}

I hope this helps.

Regards,
Mario

Hi Mario, Thanks for the code snippet. I cannot get the custom properties to read using this snippet. It just returns null.

Hi Kieran,

Please send us your PDF file and name the custom property you want to retrieve.
I’ll investigate your file.

Regards,
Mario

Hi Mario,
I have sent you an email with the file.

I was unable to reproduce the issue with the PDF file you sent us.
I was able to get the targeted custom property from it.