on ‎2006 Jul 25 3:03 PM
Hello everybody,
I have a BSP Application which handles PDF Documents. Now I want download a PDF Dokument from the Applikation Server to the Workstation. I have a HTML Link which is linked to the PDF File. If I click on the link I want to get the binary data of the PDF File in a string.
I don't have any Idea to solve this problem. Can anybody help me?
Kind regards
Axel
Request clarification before answering.
do you mean when user clicks the link, you have to read the PDF data from application server and save it in the local work station?
<i>If I click on the link I want to get the binary data of the PDF File in a string</i>.
why do you want to do that?
Regards
Raja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hell Raja,
i have a bsp Applikation which handles with PDF Files. I have a bsp-site in which shows a Link to an PDF File, that is on the application server. If I click on the link a standard popup with the bittons Open, Save, Cancel and Display comes up. The PDF File should not be directly opened in the browser if I click on the link. In "normal" Web Applications I have to modify the HTTP response and put the binray data of the PDF File into the HTTP response. I find a link (/people/thomas.jung3/blog/2004/08/09/bsp-download-to-excel-in-unicode-format) in the SDN which describe it with a Excel sheet, but for PDF's it did not work.
Kind regards
Axel
you got the right link.
just change the APP_TYPE attributes discussed in the weblog to <b>application/pdf</b> and it should work.
if it doesnt, kindly tell us what error you are getting.
also check this weblog , this may be of useful to you.
/people/sap.user72/blog/2004/11/10/bsphowto-generate-pdf-output-from-a-bsp
Regards
Raja
sorry that I forgot to tell you what kind of error I get. I get the error (there is an mistake in the PDF File)when I want to open the downloaded PDF file on my local PC. I develop following code to download the PDF:
APP_TYPE = 'APPLICATION/PDF'.
response->set_header_field( name = 'content-type' value = APP_TYPE ).
response->delete_header_field( name = if_http_header_fields=>expires ).
response->delete_header_field( name = if_http_header_fields=>pragma ).
response->set_header_field( name = 'content-disposition' value =
'attachment; filename = webforms.pdf' ).
OPEN DATASET pdfLink FOR INPUT IN BINARY MODE.
DO.
READ DATASET pdfLink INTO is_pdf.
IF sy-subrc = 0.
CONCATENATE Lv_STRING is_pdf INTO Lv_STRING.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET pdfLink.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = lv_string
MIMETYPE = 'APPLICATION/PDF;'
IMPORTING
BUFFER = l_xstring
lv_len = xstrlen( l_xstring ).
response->set_data( data = l_xstring length = lv_len ).
navigation->response_complete( ).
The code is the same as in the log /people/thomas.jung3/blog/2004/08/09/bsp-download-to-excel-in-unicode-format
But it did not work.
Kind regards
Axel
you also need to delete the cache control.
response->set_data( file_content ).
response->set_header_field( name = if_http_header_fields=>content_type
value = file_mime_type ).
response->delete_header_field( name = if_http_header_fields=>cache_control ).
response->delete_header_field( name = if_http_header_fields=>expires ).
response->delete_header_field( name = if_http_header_fields=>pragma ).
navigation->response_complete( ). " signal that response is complete
Regards
Raja
looks like there is a problem with the way you build the binary string.
<i>OPEN DATASET pdfLink FOR INPUT IN BINARY MODE.
DO.
READ DATASET pdfLink INTO is_pdf.
IF sy-subrc = 0.
CONCATENATE Lv_STRING is_pdf INTO Lv_STRING.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET pdfLink.</i>
change the concatenate statement to add BYTE mode.
CONCATENATE Lv_STRING is_pdf INTO Lv_STRING IN BYTE mode.
Regards
Raja
| User | Count |
|---|---|
| 9 | |
| 5 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.