Return to Snippet

Revision: 35521
at November 10, 2010 00:30 by poxet


Initial Code
private static string GetPropertyValueEx(string pdfData, string propertyName)
{
    var result = "";

    var propertyNameLength = propertyName.Length + 3;
    var leadLength = 4;

    var r2 = new Regex(string.Format("/{0} <[A-Za-z0-9]*>", propertyName));
    var m = r2.Match(pdfData);
    if (m.Success)
    {
        //System.Diagnostics.Debug.WriteLine(m.Index);
        var valueRaw = m.Value.Substring(propertyNameLength, m.Value.Length - propertyNameLength - 1);
        for (int i = leadLength; i < valueRaw.Length; i = i + 4)
        {
            var hexVal = valueRaw.Substring(i, 4);
            var num = (Convert.ToUInt32(hexVal, 16));
            result += (char)num;
        }
    }

    return result;
}

Initial URL


Initial Description
Provide the PDF document content as a string and it will return the data content of properties like Title or Subject.

Initial Title
Get properties from a PDF file

Initial Tags


Initial Language
C#