on 09-01-2008 5:25 PM
Hi all,
the problem i'm facing today is that i can't display a SMART FORM as a PDF in an <iframe> Tag.
If i call a simple PDF (which is stored on my PC as a local file) everything works fine and the PDF is
shown within the iframe Tag.
<html>
<head>
</head>
<body>
Test<p>
<iframe src="C:Test.pdf" width="90%" height="400" name="test"></iframe>
</body>
</html>
If i try to do the same with my test BSP the PDF is not shown within iframe Tag. Instead the iframe Tag
stays empty and the PDF is called directly by the Adobe Reader and not by my Browser (IE7).
<html>
<head>
</head>
<body>
Test<p>
<iframe src="https://vsapex2ci.daksap.de:44320/sap/bc/bsp/sap/zpdf_test/test.htm"
width="90%" height="400" name="test"></iframe>
</body>
</html>
On my test.htm only OnInitialization is implemented. Here's the Code:
DATA: lv_pdf TYPE xstring,
ls_output_data TYPE ssfcrescl,
ls_ctrl_param TYPE ssfctrlop,
lv_fm_name TYPE rs38l_fnam,
lt_lines TYPE TABLE OF tline,
lv_pdf_len TYPE i.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZTESTPDF'
IMPORTING
fm_name = lv_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
ls_ctrl_param-no_dialog = 'X'.
ls_ctrl_param-getotf = 'X'.
CALL FUNCTION lv_fm_name
EXPORTING
CONTROL_PARAMETERS = ls_ctrl_param
USER_SETTINGS = space
IMPORTING
JOB_OUTPUT_INFO = ls_output_data
* Conversion of output format OTF into PDF format
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lv_pdf_len
bin_file = lv_pdf
TABLES
otf = ls_output_data-otfdata
lines = lt_lines.
response->set_header_field( name = 'content-type'
value = 'application/pdf' ).
response->set_header_field( name = 'cache-control'
value = 'max-age=0' ).
response->set_header_field( name = 'content-disposition'
value = 'attachment; filename=test.pdf' ).
lv_pdf_len = XSTRLEN( lv_pdf ).
response->set_data( data = lv_pdf
length = lv_pdf_len ).
navigation->response_complete( ).
How can i display my generated PDF (SMART FORM) within an iframe Tag?
Regards
Mark-André
Hi MA,
sorry I am away from a test system at the moment so I can't check this out. But I seem to recall that the content-disposition header field is somehow involved in this.
Try and remove the statement...
response->set_header_field( name = 'content-disposition'
value = 'attachment; filename=test.pdf' ).
..and see what happens.
Cheers
Graham Robbo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi MA,
you could maybe try the "inline" disposition type. Check http://www.ietf.org/rfc/rfc2183.txt
Or possibly my memory of failing me and I am misleading you.
Cheers
Graham Robbo
Hi Graham,
thanks for the hint, but unfortunately this doesn't work either. With inline i get the same result as if i remove the content-disposition statement.
response->set_header_field( name = 'content-disposition'
value = 'inline; filename=test.pdf' ).
The inline Tag stays empty and the PDF is not opened.
Regards
Mark-Andre
here is the code
data: cached_response type ref to if_http_response.
create object cached_response type cl_http_response exporting add_c_msg = 1.
cached_response->set_data( file_content ).
cached_response->set_header_field( name = if_http_header_fields=>content_type
value = file_mime_type ).
cached_response->set_status( code = 200 reason = 'OK' ).
cached_response->server_cache_expire_rel( expires_rel = 180 ).
call function 'GUID_CREATE'
importing
ev_guid_32 = guid.
concatenate runtime->application_url '/' guid into display_url.
cl_http_server=>server_cache_upload( url = display_url
response = cached_response ).
return.
now in the layout use display_url as the src for iframe
Raja
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.