
Adobe Acrobat SDK
Working with Page Views and Contents
Developing Plug-ins and Applications
Determining page element types 127
The following code example accesses each element located in a
PDEContent
object.
Example 10.3
Accessing page contents
//Declare a PDEElement object
PDEElement pdeElement;
//Get the number of elements in the PDEContent object
ASInt32 eleNum = PDEContentGetNumElems(pdeContent);
//Get each element in the PDEContent object
for (int j=0; j<eleNum; j++){
pdeElement = PDEContentGetElem(pdeContent, j);
}
Determining page element types
You can determine the element type that a
PDEElement
object represents by invoking the
PDEObjectGetType
method. This method requires a
PDEObject
; however, you can pass a
PDEElement
object and cast it to a
PDEObject
. This method returns an
ASInt32
object that specifies
the element type. For example, if the element is a text element, then this method returns
kPDEText
. For a
listing of all element types, see the
Acrobat and PDF Library API Reference
.
The following code example determines the element type by adding application logic to the application
logic introduced in
“Accessing page contents” on page 127
.
Example 10.4
Determining page element types
//Declare a PDEElement object
PDEElement pdeElement;
//Get the number of elements located in the PDEContent object
ASInt32 eleNum = PDEContentGetNumElems(pdeContent);
//Get each element located within the PDEContent object
for (int j=0; j<eleNum; j++){
pdeElement = PDEContentGetElem(pdeContent, j);
//Determine if the element is a text element
if (PDEObjectGetType((PDEObject)pdeElement) == kPDEText){
//Perform an action
}