The following works for me.  I can now access all of the fields on the
Arizona A1-QRT PDF form.  I humbly submit this minor patch for peer-review
and hopeful inclusion into PoDoFo.


djenkins@ostara ~/src/podofo $ svn diff src/doc/PdfPage.cpp
Index: src/doc/PdfPage.cpp
===================================================================
--- src/doc/PdfPage.cpp (revision 1597)
+++ src/doc/PdfPage.cpp (working copy)
@@ -553,8 +553,7 @@
     {
         pAnnot = const_cast<PdfPage*>(this)->GetAnnotation( i );
         // Count every widget annotation with a FieldType as PdfField
-        if( pAnnot->GetType() == ePdfAnnotation_Widget &&
-            pAnnot->GetObject()->GetDictionary().HasKey( PdfName("FT") ) )
+        if( pAnnot->GetType() == ePdfAnnotation_Widget )
             ++nCount;
     }

@@ -570,8 +569,7 @@
     {
         pAnnot = this->GetAnnotation( i );
         // Count every widget annotation with a FieldType as PdfField
-        if( pAnnot->GetType() == ePdfAnnotation_Widget &&
-            pAnnot->GetObject()->GetDictionary().HasKey( PdfName("FT") ) )
+        if( pAnnot->GetType() == ePdfAnnotation_Widget )
         {
             if( nCount == index )
             {



djenkins@ostara ~/src/podofo $ svn diff src/doc/PdfField.cpp
Index: src/doc/PdfField.cpp
===================================================================
--- src/doc/PdfField.cpp        (revision 1597)
+++ src/doc/PdfField.cpp        (working copy)
@@ -164,13 +164,31 @@
     PdfLocaleImbue(out);
     out << "podofo_field_" << m_pObject->Reference().ObjectNumber();
 }
-
 PdfField::PdfField( PdfObject* pObject, PdfAnnotation* pWidget )
     : m_pObject( pObject ), m_pWidget( pWidget ), m_eField(
ePdfField_Unknown )
 {
+// ISO 32000:2008, Section 12.7.3.1, Table 220, Page #432.

-    PdfName fieldType = m_pObject->GetDictionary().GetKey( PdfName("FT")
)->GetName();
+    const PdfObject *pFT = m_pObject->GetDictionary().GetKey(
PdfName("FT") );

+    if (!pFT && m_pObject->GetDictionary().HasKey( PdfName ("Parent") ) )
+    {
+        const PdfObject *pTemp =  m_pObject->GetIndirectKey ( PdfName
("Parent") );
+        if (!pTemp)
+        {
+            PODOFO_RAISE_ERROR (ePdfError_InvalidDataType);
+        }
+
+        pFT = pTemp->GetDictionary().GetKey( PdfName ("FT") );
+    }
+
+    if (!pFT)
+    {
+        PODOFO_RAISE_ERROR (ePdfError_NoObject);
+    }
+
+    const PdfName fieldType = pFT->GetName();
+
     if( fieldType == PdfName("Btn") )
     {
         PdfButton button( *this );
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get 
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to