cancel
Showing results for 
Search instead for 
Did you mean: 

How do I add an attachment (xls file in my case) to the pdf

Former Member
0 Kudos

Hello,

I need to add a excel file as attachment in the generated PDF form.

Someone could tell me if this is possible and how to do it?

Thanks for the help

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You can Add the Attachments to the PDF Form, but you did not mention the scenario to add the attachments.

Please check the Program FP_PDF_TEST_16, it may help you.

Thanks.

Uma

Former Member
0 Kudos

Hello,

I don't know how to use the FP_PDF_TEST_16 to help me on my issue.

I'm generating an interactive adobe form called in a WebDynpro Abap wich is in charge to send the data from ECC, and after the user fille the form, WDA is in charge to save the data.

What I want to do is to add an attchement (xls file) to this form.

This xls will be a template filled by the user.

The best would be to allow the user to attched the ñodified xls back to the pdf before saving, but this is step 2.

First of all I need to attach a template.xls to the interactive adobe forms.

I tried JS instruction: this.importDataObject("MyFile"); but with no result.

I hope I'm clear and you could help me,

Former Member
0 Kudos

Hi,

I did little research and found that we can attach any attachment to Interactive form.

1.Get the XLS attachment(You can add File Upload UI Element(Say XLS) to your Application and Bind data,filename and mime Type Properties) with this , user can choose the XLS file to be attached from Desk top.

2. In the Interactive UI Element,bind the property "pdfsource" (Say PDF_SOURCE), this will contains the PDF in xstring format.

3. Add a button (Say Attach XLS) on the application and add an Action Method.(Say ADD)

4.in the Action Method(ADD) of the Button, follow the Steps.

1. Get the File(XLS File) Uploaded,Mimi Type from File Uploade UI Element(Say lv_xls_data,lv_mimetype,lv_file_name)

2. get the pdf source( PDF_SOURCE) from Interactive form.(Say lv_pdf_source)

use the Following Code

 

DATA: l_fp           TYPE REF TO if_fp, 
        l_pdfobj       TYPE REF TO if_fp_pdf_object, 
        l_pdf          TYPE xstring, 
        l_att          TYPE xstring, 
        l_fpex         TYPE REF TO cx_fp_runtime, 
        l_type         TYPE string, 
        l_errmsg       TYPE string, 
        l_short        TYPE sdba_actid, 
        l_ext          TYPE sdba_funct, 
        l_filename     TYPE skwf_filnm, 
        l_mimetype     TYPE skwf_mime, 
        l_attachment   TYPE sfpattachments, 
        l_attachments  TYPE tfpattachments, 
        l_len          TYPE i, 
        l_tab          TYPE tsfixml, 
        p_dest         TYPE rfcdest . 

  MOVE cl_fp=>get_ads_connection( ) TO p_dest. 
  l_mimetype   = lv_mimetype. 
* Get FP reference. 
  l_fp = cl_fp=>get_reference( ). 

  TRY. 
*     Create PDF Object. 
      l_pdfobj = l_fp->create_pdf_object( connection = p_dest ). 

*     Set document. 
      l_pdfobj->set_document( pdfdata = lv_pdf_source ). 

       l_attachment-FILENAME = lv_file_name."Name of the Attached File. 
      l_attachment-mimetype    = lv_mimetype. 
      l_attachment-description = 'XLS_Attachment'.    
     l_attachment-data        = lv_xls_data."XLS File to Be attached . 
      INSERT l_attachment INTO TABLE l_attachments. 
      l_pdfobj->set_attachments( attachments = l_attachments ). 

*     Execute, call ADS. 
      l_pdfobj->execute( ). 

*     Get result. 
      l_pdfobj->get_document( IMPORTING pdfdata = l_pdf ). 


    CATCH cx_fp_runtime_internal INTO l_fpex.           "#EC NO_HANDLER 
    CATCH cx_fp_runtime_system INTO l_fpex.             "#EC NO_HANDLER 
    CATCH cx_fp_runtime_usage INTO l_fpex.              "#EC NO_HANDLER 
  ENDTRY. 


Finally "l_pdf" contains the PDF with Attached XLS and you can send this as PDF Document.

Thanks.

Uma