on 05-04-2007 12:11 PM
Hi,
how can we display logos dynamically in PDF forms
can anybody provide sample code
Message was edited by:
Srinivas Sriram
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:-)
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.