//Load the existing PDF document.
PdfLoadedDocument pdfLoadedDocument = new PdfLoadedDocument(@"input.pdf");
//Get all the document properties.
PropertyInfo[] documentProperties = pdfLoadedDocument.GetType().GetProperties(BindingFlags.Instance |
BindingFlags.NonPublic |
BindingFlags.Public);
foreach (PropertyInfo property in documentProperties)
{
//Get the PDF Catalog object
if (property.Name == "Catalog")
{
//Get PdfCatalog
object catalogProps = property.GetValue(pdfLoadedDocument, null);
//Get all the catalog properties.
PropertyInfo[] catalogProperties = catalogProps.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (PropertyInfo prop in catalogProperties)
{
//Get the items property.
if (prop.Name == "Items")
{
//Get Items.
IDictionary ss = prop.GetValue(catalogProps, null) as IDictionary;
foreach (var key in ss.Keys)
{
//Catalog dictionary values.
object value = ss[key];
}
break;
}
}
break;
}
}
|