Below are the steps to display a PDF in UI5 application.
createContent : function(oController) {
var html = new sap.ui.core.HTML();
html.setContent("<div id=\"divPdf\"><iframe id='pdfFrame' style=\"height:1000px;\"></iframe>");
return new sap.m.Page({
title : "PDF View",
showNavButton : true,
navButtonPress : oController.fnGoback,
content : [ html ],
footer : new sap.m.Bar({
})
});
}
onAfterRendering: function() {
var pdfUrl = "http://blasthemy.com/sap/TechEd13/1_Session_PDFs/CD/CD119/CD119.pdf";
$("pdfFrame").attr("src",pdfUrl);
$(function(){
if(/iPhone|iPod|iPad/.test(navigator.userAgent))
{
$("#divPdf").css({
'overflow':'scroll',
'width':'100%',
'height': isNaN(window.innerHeight)?window.clientHeight :window.innerHeight,
'position':'absolute',
'-webkit-overflow-scrolling':'touch'
});
}
else
{
$("#divPdf").css({
'overflow':'scroll',
'width':'100%',
'height': isNaN(window.innerHeight)?window.clientHeight :window.innerHeight,
'position':'absolute',
'-webkit-overflow-scrolling':'auto'
});
}
});
},
Note : This code works on all the devices.
Regards,
KK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
10 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |