Issue
I have a SAPUI js controller that will call a servlet to display a pdf file. However, the url call returns a response which I believe is a pdf xstring format. Basically if i open the url directly it will just display the pdf, but since i am calling the servlet, there is no window opened.
Following is my call.
$.ajax({
url : 'http://localhost/pentaho',
type: 'GET',
crossDomain: true,
success : function(data) {
},
error : function(data){
console.log("Error");
}
});
I am using GET as i would need to pass some parameters to the servlet but I just require the pdf to be displayed. The ajax call is successfull with the variable (data) filled with which I believe the xstring binary pdf.
Question : 1. Can i call the servlet url and let the pdf open in another window without a response ? 2. How do i format the response string to display as pdf in sapui5 if above is not possible.
The data stream looks like this.
%PDF-1.6 %âãÏÓ 21422 0 obj <>stream hÞœ›Q,Çq¥ÿÊ
Hope you can help shed some light into the matter.
Thanks. Anand
Solution
Both suggestion works and gave me some hints to progress. Finally went with the following.
Set the source with the URL options as parameters
var source = "/pentaho?P_WERKS="+oClient;
var _pdfurl = source;
this.oPDFViewer = new sap.m.PDFViewer();
this.oPDFViewer.setSource(_pdfurl);
this.oPDFViewer.open();
Thanks. Anand
Answered By - Anand Muthu