pdfpdf-generationabapwebdynpro

How can I generate and download a pdf file in WebDynpro for ABAP?


I've got a task to create a webdynpro that given some inputs, can generate a pdf file with questions and the user should be able to download it somewhere. My question is, how can i generate a PDF in WDs and how do i prompt the download?


Solution

  • I do not know how to do it with Adobe Forms but I surely have seen that done using SmartForms.

    When you execute the function module assigned to a smartform there is an EXPORTING parameter for it job_output_info.

    With this parameter you execute then the function module CONVERT_OTF with following parameters.

    EXPORTING
      format = 'PDF'
    IMPORTING
      bin_file = e_file_as_xstring
    TABLES
      otf = job_output_info-otfdata[]
      lines = lt_pdf_file_lines
    

    Then if you are using WebDynpro for ABAP use the following method to let the user download the file.

    wdr_task=>client_window->client->attach_file_to_response(
       i_filename  = 'Filename.pdf'
       i_content   = e_file_as_xstring
       i_mime_type = 'pdf/application'
    )
    

    Not sure how it might work with Adobe Forms, but if you are able to generate the OTF content you should be able to do it as well. On the other hand maybe you are just able to get the PDF as xstring, then the OTF part will not be needed at all.

    Maybe this article will help you to know how convert the Adobe Form to xstring: Getting a PDF in an xstring format in the ABAP environment