on 10-31-2015 4:17 PM
Hello Experts,
I have a requirement where i need to display PDF file in a new tab.
I have data in base 64 that i am getting from Backend into the Gateway server.( i can get in xstring format as well)
Now when i try to use-
1. window.open("data:application/pdf," + escape(a) , "_blank");
a will have the pdf data
This works well in Chrome but fails in Internet Explorer.
What i need exactly is like webdynpro Framework where by using below we used to get pdf loaded in New tab which will have native PDF print and download options:-
cl_wd_runtime_services=>attach_file_to_response(
* EXPORTING i_filename = 'File_pdf
EXPORTING i_filename = lv_file_name
i_content = lv_content
i_mime_type = 'application/pdf' "
i_in_new_window = abap_true
i_inplace = abap_true ).
Please let me know Guys how to achieve this functionality.I need solution that works in IE11.
Thanks in advance,
Sujit
Hi!
You need change header paremeter 'Content-Disposition'.
Return default value in odata method get_stream 'Content-Disposition': 'attachment', when open attach file you see dialog box Open or Download.
METHOD /iwbep/if_mgw_appl_srv_runtime~get_stream.
DATA: ls_header | TYPE ihttpnvp. |
ls_header-name = 'Content-Disposition'. | |
IF lv_show_as_attach = abap_true. | |
ls_header-value = 'attachment' && ';' && 'filename=' && lv_file_name && '.' && lv_doc_type. | |
ELSE."Try this | |
ls_header-value = 'inline' && ';' && 'filename=' && lv_file_name && '.' && lv_doc_type. | |
ENDIF. | |
set_header( is_header = ls_header ). |
ENDMETHOD.
See this about Content-Disposition
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nik,
Yes it helped- I am using an URL and by using content disposition i am displaying the PDF.
Now when i use the disposition- value= inline, the file name which i pass doesnot seems to pick up when i try to save the pdf(IE11) , but it works well when used on chrome.
Also, when i use the disposition value as attachment- it picks up the filename but it gets downloaded automatically, it doesn't show the pdf on the window.
Please let me know if we can fix the inline- filename issue on IE11.
Thanks,
Sujit
Hi Nik,
I followed the above thread(Display Smartform (PDF) in SAPUI5)...
I did not get an Error.. But MyPDF content is not visible on the page..Just the IFRAME is visible. Please tell me what could be the problem. Urgent help needed ...
Why my PDF Content is not getting Displayed. Please tell me .. I am in serious need of some assistance.
Fo IE. It is user dependent.
You can't directly control this, because it's an option controlled by Internet Explorer users.
Opening pages using Window.open with a different window name will open in a new browser window like a popup, OR open in a new tab, if the user configured the browser to do so.
Reference : javascript - Programmatically open new pages on Tabs - Stack Overflow
Thanks,
Karthik A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Karthik,
Window.open(); is opening the new tab for us but since IE doesnot support DATA URL so the code that i have used for google chrome doesnot seems to be working.
Basically i have a button and on the click of that i need to perform this action.
Please let me know if we can work out this in Internet Explorer.
Thanks for your response.
Hi Sujit,
Could you please try using sap.m.URLHelper JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.m.URLHelper
Syntax:
jQuery.sap.require("sap.m.URLHelper");
sap.m.URLHelper.redirect(sUrl, true);
Thanks,
Naga
Hi Naga Prakash,
I followed the above thread... I did not get an Error.. But MyPDF content is not visible on the page..Just the IFRAME is visible. Please tell me what could be the problem. Urgent help needed ...
Why my PDF Content is not getting Displayed. Please tell me .. I am in serious need of some assistance.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
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.