Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9656

Display PDF

$
0
0

Hi,

I have a requirement to display the pdf on the fiori screen, for that I have written an oData service in the backend which is working fine (tested in gateway client). On the UI side, i am using below code in view and controller.

 

So, while testing the scenario, i noticed that the xstring is coming from the backend but pdf is not getting displayed on the screen (empty box appears on clicking "View PDF" button) instead of that pdf is getting downloaded on the desktop with the name as "entity" (screenshot below).

Any idea, what exactly i am missing? In advance, Thanks for the help!

 

Capture.PNG

 

XML view -

<mvc:View xmlns:core="sap.ui.core" xmlns:html1="sap.ui.core.HTML" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"

    xmlns:html="http://www.w3.org/1999/xhtml" controllerName="quoteapplication.controller.PDFDisplay">

    <Page id="pagePDFDisplay" navButtonPress="_navBack" title="PDF Display" busy="{viewModel>/busy}" showNavButton="true">

        <content>

            <Button text="View PDF" width="100px" id="__button0" press="onSave1"/>

            <Panel id="pdfPanel" backgroundDesign="Solid" expandable="false" height="90%"/>

        </content>

    </Page>

</mvc:View>

 

controller -

 

onSave1: function() {
var sURI = '/sap/opu/odata/sap/ZPROJECT_SRV_05/';
var oModel = new sap.ui.model.odata.ODataModel(sURI, false);
var html = new sap.ui.core.HTML();
var oPanel = this.getView().byId("pdfPanel");
var sRead = "/pdfSet('5')/$value";
oModel.read(sRead, null, null, true, function(oData, oResponse) {
    var pdfURL = oResponse.requestUri;
    html.setContent("<iframe id='sapUI_object' src=" + pdfURL + " width='800' height='800' seamless></iframe>");
oPanel.addContent(html);
}, function() {
alert("Read failed");
});

 

}

    });

 

Thanks

Amit Srivastava


Viewing all articles
Browse latest Browse all 9656

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>