forked from CmIm/sapui5-display_smartform_pdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
112 lines (75 loc) · 2.51 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script src="resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.ui.commons,sap.ui.table"
data-sap-ui-theme="sap_bluecrystal">
</script>
<!-- add sap.ui.table,sap.ui.ux3 and/or other libraries to 'data-sap-ui-libs' if required -->
<script>
var sURI = '/sap/opu/odata/sap/ZTESTPDF_SRV/';
oModel = new sap.ui.model.odata.ODataModel(sURI, false),
sap.ui.getCore().setModel(oModel);
//create the ApplicationHeader control
var oAppHeader = new sap.ui.commons.ApplicationHeader("appHeader");
//configure the branding area
oAppHeader.setLogoText("Display Smartform (PDF) in SAPUI5");
//configure the welcome area
oAppHeader.setDisplayWelcome(true);
oAppHeader.setUserName("Chandrashekhar Mahajan");
//configure the log off area
oAppHeader.setDisplayLogoff(true);
oAppHeader.placeAt("content");
//Create Contact Details UI
var oMatrix = new sap.ui.commons.layout.MatrixLayout({
id : 'matrix4',
layoutFixed : true,
width : '1000px',
columns : 5,
widths : ['150px', '250px', '200px', '200px', '200px'] });
var oCell = new sap.ui.commons.layout.MatrixLayoutCell({
colSpan: 5 });
var oTV = new sap.ui.commons.TextView({
id : 'TV-Head',
text : 'Invoice Details for Customer',
design : sap.ui.commons.TextViewDesign.H1 });
oCell.addContent(oTV);
oMatrix.createRow(oCell);
var oLabel = new sap.ui.commons.Label({
id : 'L-Name',
text : 'Customer Number' });
var oTF = new sap.ui.commons.TextField({
id : 'TF-Name',
tooltip : 'Customer Number',
width : '200px' });
oLabel.setLabelFor(oTF);
oMatrix.createRow(oLabel, oTF);
//Create a panel and html instances
var oPanel = new sap.ui.commons.Panel();
var html = new sap.ui.core.HTML();
var oButton = new sap.ui.commons.Button({
id : 'B-Create',
text : 'Display PDF',
width : '10em',
press : function(){
var sRead = "/pdfset(customer='" + oTF.getValue() + "')" ;
oModel.read( sRead, null, null, true, function(oData, oResponse){
var pdfURL = oData.url;
html.setContent("<iframe src=" + pdfURL + " width='700' height='700'></iframe>");
oPanel.addContent(html);
oPanel.placeAt("content");
},function(){
alert("Read failed");});
}
});
oMatrix.createRow(oButton);
//attach it to some element in the page
oMatrix.placeAt('content');
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>