cancel
Showing results for 
Search instead for 
Did you mean: 

Open PDF File in New Tab in UI5 Applicaiton on Internet Explorer

former_member575260
Participant
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

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

former_member575260
Participant
0 Kudos

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

0 Kudos

Hi, Sujit,

File name in English?

former_member575260
Participant
0 Kudos

Hi Nik,

Yes in English only.

Thanks,

Sujit

0 Kudos

Hmmm

try in abap get_stream add code

lv_file_name = escape( val = lv_file_name format = cl_abap_format=>e_uri ).

ls_header-name = 'Content-Disposition'.

ls_header-value = 'inline' && ';' && 'filename=' && lv_file_name && '.' && lv_doc_type.

set_header( is_header = ls_header ).

former_member575260
Participant
0 Kudos

Hi Nik,

No Luck with this..

IE 11 is still using the last part of URL as default file name in the save dialog box of window.

Thanks,

Sujit

Phani_Kumar
Participant
0 Kudos

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.

karthikarjun
Active Contributor
0 Kudos

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

former_member575260
Participant
0 Kudos

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.

NagaPrakashT
Contributor
0 Kudos

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

former_member575260
Participant
0 Kudos

Hi Prakash,

Well, how can we pass parameter that will contain pdf data to be passed to launch the new tab.

with window.open java scripts we can launch new window but how to pass pdf content is the issue.

Thanks,

Sujit

NagaPrakashT
Contributor
0 Kudos

Hi Sujit,

Are getting the data from gateway system.Have you implemented GET_STREAM method in the service to get the attachments/pdf data ?

These may help you in displaying the PDF data.

Thanks,

Naga

Phani_Kumar
Participant
0 Kudos

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.