cancel
Showing results for 
Search instead for 
Did you mean: 

How to parse data from pdfSource which is of type xstring?

Former Member
0 Kudos

Hi,

I have a pdf form in WDA which is using pdfSource. This is of type xstring and i want to convert this xtring such that i am able to read data from pdf.

I don't want to use templateSource as i need to pass xstring to some FM and hence it will create performance issue if i use templateSource in WDA view and then generate it again to get pdf in xtsring format.

Any help will be appreciated.

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

RalfRuth
Employee
Employee
0 Kudos

Hi,

Try this:


  DATA pdf TYPE xstring.
  DATA form_data_xml TYPE xstring.
  DATA if_fp TYPE REF TO if_fp.
  DATA pdf_object TYPE REF TO if_fp_pdf_object.
  DATA cx_fp_exception TYPE REF TO cx_fp_exception.

  ...
  context_element->get_attribute(
    EXPORTING
      name =  `PDF_SOURCE`
    IMPORTING
      value = pdf ).
  TRY.
      if_fp = cl_fp=>get_reference( ).
      pdf_object =  if_fp->create_pdf_object( ).
      pdf_object->set_document( pdfdata = pdf ).
      pdf_object->set_task_extractdata( ).
      pdf_object->execute( ).
      pdf_object->get_data( IMPORTING formdata = form_data_xml ).
    CATCH cx_fp_exception INTO cx_fp_exception.
      "TODO: error handling
  ENDTRY.
  "TODO: parse form_data_xml and extract data

Nevertheless, I'm not sure that this solution is better/faster than the built-in Web Dynpro functionality: If you use the interactiveForm uielement as intended (i.e. bind templateSource and dataSource plus pdfSource in your case), Web Dynpro creates the pdf for you and provides a copy of it in pdfSource (as xstring), i.e. you don't have to generate the pdf again!

Ralf

ChrisPaine
Active Contributor
0 Kudos

This is the logic that the built in functionality (Adobe interactive UI element) uses and then parses the xml into your context.

Also it should be noted that this functionality only works on PDF documents/forms that have been generated using the ADS. You cannot read PDFs generated from other sources.

Unless you have a situation where you will be uploading multiple different ADS generated forms and trying to get at their content, I think you'd be much better off just using the standard interactive form ui element and binding to the interface.

Cheers,

Chris