Hello all,
I want to display to local PDF files in my sap ui5 application but it is not showing the files.
I tried the following but it does not work.
I cannot make the path work properly
I have the files on my src folder inside the APP.
View code followed by controller code:
<PDFViewer class="sapUiSmallMarginEnd" source="webapp/src/dummy.pdf" title="{/Title1}" height="{/Height}" width="auto">
<layoutData>
<FlexItemData growFactor="1"/>
</layoutData>
</PDFViewer>
<PDFViewer class="sapUiSmallMarginBegin" source="{/Source}" title="{/Title2}" height="{/Height}" width="auto">
<layoutData>
<FlexItemData growFactor="1"/>
</layoutData>
</PDFViewer>
-------------------------------------------------------
function(jQuery, Controller, JSONModel) {
"use strict";
var PageController = Controller.extend("PdfViewTest.controller.App", {
onInit : function () {
this._sValidPath = sap.ui.require.toUrl("sap/m/sample/PdfViewTest") + "/sample.pdf"; // sap.ui.core.URI("webapp/src/dummy.pdf")
this._sInvalidPath = sap.ui.require.toUrl("sap/m/sample/PdfViewTest") + "/sample_nonexisting.pdf";
this._oModel = new JSONModel({
Source: this._sValidPath,
Title1: "My Title 1",
Title2: "My Title 2",
Height: "600px"
});
this.getView().setModel(this._oModel);
},
onCorrectPathClick: function() {
this._oModel.setProperty("/Source", this._sValidPath);
},
onIncorrectPathClick: function() {
this._oModel.setProperty("/Source", this._sInvalidPath);
}
});
return PageController;