cancel
Showing results for 
Search instead for 
Did you mean: 

how to display logo dynamically in PDF forms

Former Member
0 Kudos

Hi,

how can we display logos dynamically in PDF forms

can anybody provide sample code

Message was edited by:

Srinivas Sriram

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

insert an attribute of type Graphic in context of your adobe form (in transaction SFP). Set the propertie Field to an attribute from your inteface of the type RAWSTRING. Set the propertie MIME Type to an attribute from your interface of the type STRING.

You can use following code for filling attributes of your interface:

FORM importImg
    CHANGING p_img_content TYPE xstring
             p_img_mime_type TYPE string.
DATA: lt_file_table TYPE filetable,
      lt_rawtab TYPE TABLE OF OCS_F_DATA,
      l_rc  TYPE I,
      l_filelength TYPE I,
      l_filename   TYPE string.
FIELD-SYMBOLS: <ls_file_table> LIKE LINE OF lt_file_table,
               <ls_rawtab> LIKE LINE OF lt_rawtab.
CLEAR: p_img_content, p_img_mime_type.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
  EXPORTING
    WINDOW_TITLE            = 'Open image'
     FILE_FILTER             = 'JPG files (*.jpg)|*.jpg|All Files (*.*)|*.*'
  CHANGING
    FILE_TABLE              = lt_file_table
    RC                      = l_rc
  EXCEPTIONS
    FILE_OPEN_DIALOG_FAILED = 1
    CNTL_ERROR              = 2
    ERROR_NO_GUI            = 3
    NOT_SUPPORTED_BY_GUI    = 4
    others                  = 5.
IF SY-SUBRC <> 0.
   l_rc = 1.
   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF lt_file_table[] IS INITIAL.
   RETURN.
ENDIF.
READ TABLE lt_file_table ASSIGNING <ls_file_table> INDEX 1.
l_filename = <ls_file_table>-filename.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
  EXPORTING
    FILENAME                = l_filename
    FILETYPE                = 'BIN'
  IMPORTING
    FILELENGTH              = l_filelength
  CHANGING
    DATA_TAB                = lt_rawtab
  EXCEPTIONS
    others                  = 19.
IF SY-SUBRC <> 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT lt_rawtab ASSIGNING <ls_rawtab>.
  CONCATENATE p_img_content <ls_rawtab>-data INTO p_img_content IN BYTE MODE.
ENDLOOP.
* MIME Type of the file.
DATA: l_filename_formime TYPE SKWF_FILNM,
      l_img_mime_type TYPE SKWF_MIME.
l_filename_formime = l_filename.
CALL FUNCTION 'SKWF_MIMETYPE_OF_FILE_GET'
  EXPORTING
    FILENAME                   = l_filename_formime
  IMPORTING
    MIMETYPE                   = l_img_mime_type.
p_img_mime_type = l_img_mime_type.
ENDFORM.

Regards

Michal

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

you can use control Image and in the propertie URL write an adresse of your image (http:// ...). But Reader will ask users if they want to access this adress. Or you can use control Image Field and you can bind it with a node of type binary which you prefill with a content of your image file.

Regards

Michal

Former Member
0 Kudos

Hi Michal,

Thanks for ur response I know that we have to use image field and bind it, Can you please let me know how could I convert image file to binary with a sample code.

Former Member
0 Kudos

Hi Srinivas,

In order to bind a dynamic image u need not write a code for binary conversion of the image.

If working in webdynpro u can bind the image with the code

below

try { String url = WDURLGenerator.getAbsoluteWebResourceURL( wdComponentAPI.getDeployableObjectPart(), "sap_online_shop.jpg"); wdContext.currentDataSourceElement().setSapOnlineShopUrl(url); } catch(Exception e) { throw new WDRuntimeException(e); }

nd FormCalc script statement, which enables the dynamic integration of the image.

Show: initialize

Script: this.value.image.href = xfa.resolveNode(this.value.image.href).value; Language: FormCalc

Run At: Client

Cheers

Swathi

Do offer pts:-)

Former Member
0 Kudos

thanks swathi thanks for your response but iam not using webdynpro iam using normal abap and calling the PDF form from the program. Is there any function module that would convert the Image file to binary, becoz iam maintianing a table for holding the image data.

Former Member
0 Kudos

Hi Swarhi,

I'm working with webdynpro in java; it´s ok, but, when i do click on the image its open a popup of 'Select Image File'... how i do disable it?. thanks.

Former Member
0 Kudos

Hi,

You selected the 'Image field' element instead of 'Image'. As you cannot add scripting events to an image, embed it in a subform where you specify your events.

Regards,

Francois

Former Member
0 Kudos

Its working fine but in my case image is inside form where its not working is giving SOM Exception error and i cant put that image outside the form.So can u suggest me what to do......