The PDF object API allows communicating with the ADS and carrying out necessary functions from an ABAP program. These include creation of forms and extraction of data, and so on. In this recipe, we will see the code that will allow you to communicate with the ADS in order to generate a PDF form object for a filled PDF form and then extract necessary data from it. We assume that we are not using the Adobe offline infrastructure.
There are a few classes and interfaces involved. The factory class CL_FP
is used for creating the PDF document object instance that is based on the class CL_FP_PDF_OBJECT
(using interface IF_FP_PDF_OBJECT
). The main implementation class for the PDF object is CL_FP_PDF_OBJECT
.
In this recipe, we will see how a filled form may be programmatically processed using the ADS functions and then the entered data within the form may be extracted. We assume that the form to be processed is stored in the variable MYFORM
having type XSTRING
. The recipe takes on from there. Only the part that is relevant to the instantiation of the PDF object and extraction is shown in the recipe.
Follow these steps:
IF_FP
and the interface IF_FP_PDF_OBJECT
.GET_REFERENCE
of the CL_FP
interface is then called and the object returned is stored in MY_FP
.CREATE_PDF_OBJECT
method of the CL_FP
class. The value ADS
is passed for the CONNECTION
parameter. Then the SET_DOCUMENT
method is called and the PDF data contained in the xstring MYFORM
is assigned to it.SET_EXTRACTDATA
method of the class CL_FP_PDF_OBJECT
is then called followed by the EXECUTE
method.GET_DATA
method is then called.TRY
and ENDTRY
statements and the Exception
class CX_FP_RUNTIME_SYSTEM
may be used.We initially declare references to the factory class CL_FP
and the main implementation class CL_IF_PDF_OBJECT
(using appropriate interface names). The static GET_REFERENCE
method the CL_FP
class is then called and an object is instantiated belonging to class CL_FP
. This is pointed to by the reference variable MY_FP
.
The CREATE_PDF_OBJECT
method of the factory class CL_FP
is then called to create the PDF object instance, the reference to which is stored in the variable MYPDFOBJECT
.
The SET_DOCUMENT
method is called for the variable MYPDFOBJECT
in order to link the PDF data stored in the MYFORM
xstring. The SET_EXTRACTDATA
method is then called in order to specify the extraction of the entered data in the form. The Execute
method allows the PDF form to be passed to the ADS and the extraction of data to takes place.
It is only at the
EXECUTE
method that the ADS comes into action (the Execute
method triggers execution of all method beginning with SET_
). The data entered in the form is extracted and is made available in XML format. Once the extraction has been done, the GET_DATA
method may be called in order to read the form data into the xstring XMLDATA
. We can use transformations to place the data in ABAP variables.
3.149.254.103