on 09-24-2007 3:27 AM
Hi All,
With the help of Craigs Blog
/people/sap.user72/blog/2004/11/10/bsphowto-generate-pdf-output-from-a-bsp
I coded a BSP to display PDF from a spool number.
I did everything mentioned in the blog. When i execute, the pdf gets displayed, however the data is some unconverted junk data. Can any one suggest what i am doing wrong here.
Heres the coding in the Event handler (OnInputProcessing) :
DATA: radioButtonGroup TYPE REF TO CL_HTMLB_RADIOBUTTONGROUP.
DATA: fileUpload TYPE REF TO CL_HTMLB_FILEUPLOAD.
DATA: cached_response TYPE REF TO if_http_response.
DATA: response TYPE REF TO if_http_response.
DATA: guid TYPE guid_32.
fileUpload ?= CL_HTMLB_MANAGER=>GET_DATA(
request = request
id = 'myUpload'
name = 'fileUpload' ).
file_name = fileUpload->file_name.
file_mime_type = fileUpload->file_content_type.
file_length = fileUpload->file_length.
file_content = fileUpload->file_content.
radioButtonGroup ?= CL_HTMLB_MANAGER=>GET_DATA(
request = request
id = 'display_type'
name = 'radioButtonGroup' ).
display_type = radioButtonGroup->selection.
IF display_type = 'convertspool'.
DATA: itab TYPE TLINE,
witab TYPE TABLE OF TLINE,
output TYPE STRING,
outputx TYPE XSTRING.
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = 0002344365
NO_DIALOG = 'X'
TABLES
PDF = witab
EXCEPTIONS
ERR_NO_ABAP_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DESTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 8
ERR_BTCJOB_SUBMIT_FAILED = 9
ERR_BTCJOB_CLOSE_FAILED = 10
others = 11.
if sy-subrc EQ 0.
LOOP AT witab INTO itab.
CONCATENATE
output
itab-tdline
INTO output.
ENDLOOP.
****Convert the Character String to Binary String
data: r_string type string.
data: R_XSTRING type xstring.
call function 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = output
IMPORTING
buffer = outputx.
CREATE OBJECT cached_response TYPE CL_HTTP_RESPONSE EXPORTING
add_c_msg = 1.
l_pdf_len = xstrlen( outputx ).
cached_response->set_data( data = outputx
length = l_pdf_len ).
cached_response->set_header_field( name =
if_http_header_fields=>content_type
value = 'application/pdf' ).
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 '.pdf' INTO
display_url.
cl_http_server=>server_cache_upload( url = display_url
response = cached_response ).
ENDIF.
RETURN.
ENDIF.
Regards
Sri
Done. Set the standard zoom in PDF settings.
Thanks
Sri
Message was edited by:
Sri Tayi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
With the help of some other posts and blogs.. am able to display the pdf now.
However, the default magnification(zoom) is always 44.5%. Any ideas as to how this can be increased or set to a default value.
Sri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
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.