Skip to Content
author's profile photo Former Member
Former Member

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

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Oct 27, 2010 at 08:55 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.