
Adobe Acrobat SDK
Working with Acrobat Extended APIs
Developing Plug-ins and Applications
PDF Consultant and Accessibility Checker extended API 220
As the consultant traverses a PDF document, gathering objects of interest, it can perform the following
tasks:
●
Walk a given hierarchy
●
Keep track of cycles
●
Ensure that objects are only visited once, if desired
●
Recognize object types
●
Keep a traversal stack list
Acrobat agents
The consultant accomplishes its task by using agents, which are pieces of code you design to gather the
statistics and recommend to the consultant the necessary repairs of the document. Separate agents
handle each area of analysis and repair. The agents inform the consultant of the particular types of objects
in which they are interested by registering with the consultant. When the consultant has one or more
agents registered, it hands each object of the requested type(s) in the current document to each of the
agents that requested that type. The consultant gives objects to each agent in turn, depending on the
order in which they registered.
The consultant must intelligently determine the type of each object it comes across (both direct and
indirect), so it can pass appropriate objects to the agents, or replace or remove ones that it has been
instructed to handle itself. The consultant communicates directly with agents, keeping lists of which
agents are interested in which objects, and obtaining instructions from the agent as to an object’s
visitation status.
Agents can perform their own repairs and modifications to the PDF document, and can return a corrected
object to serve as a replacement for the object the consultant originally passed to it. Agents can also
modify the Cos graph themselves (including adding or removing Cos objects or modifying the contents
such as keys or array elements).
The consultant keeps a list of each object (starting with the object which began the traversal) that it visits
on its way to any given object. Agents must be careful not to make any modifications that would affect any
of the objects in the list, which is referred to as the traversal stack. For this reason, agents can specify a
post-processing callback that the consultant invokes once it has finished traversing the entire document.
Reclassifying and revisiting
If an agent or the consultant modifies an object, the consultant reclassifies that object, possibly changing
its type.
Agents also pass visitation flags to the consultant that determine how object types should be visited.
Limiting the traversal is important, as PDF documents are graphs, arbitrarily complex, and often there are
many ways to visit a single object. If the consultant reclassifies an object, it may also change the way that
object is revisited. You must keep this in mind as you develop your agents.
Agent architecture
Your agent code will primarily consist of a structure, as defined in the ConsExpt.h header file. Acrobat
provides a C++ wrapper class to facilitate writing agents; you can derive an agent class from this base class.