Frequently Asked Question

Get OpenAction metadata using Advanced properties (Windows)
Last Updated 11 months ago

Using the Advanced properties, you can get the initial View mode (managed by Acrobat) from metadata, check the below code:

Note: a premium license is needed.

String viewMode = "Fit";
PDFRef pdfRef = m_doc.Advance_GetRef();                   
PDFObj rootObj = m_doc.Advance_GetObj(pdfRef);
if (rootObj != null)
{
         int count = rootObj.DictGetItemCount();
         for (int cur = 0; cur < count; cur++)
         {
                String tag = rootObj.DictGetItemTag(cur);
                PDFObj item = rootObj.DictGetItem(cur);
                if (tag.Equals("OpenAction") && item.type == 8)
                {
                      rootObj = m_doc.Advance_GetObj(item.RefVal);
                      if (rootObj.DictGetItemCount() > 0 && rootObj.DictGetItem(0).type == 6)
                      {
                            item = rootObj.DictGetItem(0);
                            int arrayCount = item.ArrayGetItemCount();
                            if (arrayCount > 1)
                            {
                                  viewMode = item.ArrayGetItem(1).NameVal;
                                  break;
                            }
                       }
                 }
          }
}   


Loading ...