forked from neodynamic/WebClientPrint-ASPNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemoPrintFilePDF.aspx
More file actions
229 lines (189 loc) · 11.3 KB
/
DemoPrintFilePDF.aspx
File metadata and controls
229 lines (189 loc) · 11.3 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<%@ Page Title="Advanced PDF Printing" Language="C#" MasterPageFile="~/MasterPage.master" %>
<script runat="server">
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style type="text/css">
.glyphicon-refresh-animate {
-animation: spin .7s infinite linear;
-webkit-animation: spin2 .7s infinite linear;
}
@-webkit-keyframes spin2 {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
@keyframes spin {
from {
transform: scale(1) rotate(0deg);
}
to {
transform: scale(1) rotate(360deg);
}
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderBody" runat="Server">
<div class="container">
<div class="row">
<div class="col-md-12">
<h3><a href="Samples.aspx" class="btn btn-md btn-danger"><i class="fa fa-chevron-left"></i></a> Advanced PDF Printing</h3>
<p>
With <strong>WebClientPrint for ASP.NET</strong> solution you can <strong>print PDF files</strong> right to any installed printer at the client side with advanced settings.
</p>
<div class="form-group well">
<h4>Click on <strong>"Get Printers Info"</strong> button to get Printers Name, Supported Papers and Trays</h4>
<div class="row">
<div class="col-md-3">
<a onclick="javascript:jsWebClientPrint.getPrintersInfo(); $('#spinner').css('visibility', 'visible');" class="btn btn-success">Get Printers Info...</a>
</div>
<div class="col-md-9">
<h3 id="spinner" style="visibility: hidden"><span class="label label-info"><span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span>Please wait a few seconds...</span></h3>
</div>
</div>
<div class="row">
<div class="col-md-3">
<label for="lstPrinters">Printers:</label>
<select name="lstPrinters" id="lstPrinters" onchange="showSelectedPrinterInfo();" class="form-control"></select>
</div>
<div class="col-md-3">
<label for="lstPrinterTrays">Supported Trays:</label>
<select name="lstPrinterTrays" id="lstPrinterTrays" class="form-control"></select>
</div>
<div class="col-md-3">
<label for="lstPrinterPapers">Supported Papers:</label>
<select name="lstPrinterPapers" id="lstPrinterPapers" class="form-control"></select>
</div>
<div class="col-md-3">
<label for="lstPrintRotation">Print Rotation (Clockwise):</label>
<select name="lstPrintRotation" id="lstPrintRotation" class="form-control">
<option>None</option>
<option>Rot90</option>
<option>Rot180</option>
<option>Rot270</option>
</select>
</div>
</div>
<div class="row">
<div class="col-md-3">
<label for="txtPagesRange">Pages Range: [e.g. 1,2,3,10-13]</label>
<input type="text" class="form-control" id="txtPagesRange">
</div>
<div class="col-md-3">
<label><input id="chkPrintInReverseOrder" type="checkbox" value="">Print In Reverse Order?</label>
</div>
<div class="col-md-3">
<div class="checkbox">
<label id="lblDriverDuplexPrinting"><input id="chkDriverDuplexPrinting" type="checkbox" value="">Use Driver Duplex Printing?</label>
</div>
<div class="checkbox">
<label><input id="chkManualDuplexPrinting" type="checkbox" value="">Use Manual Duplex Printing?</label>
</div>
</div>
<div class="col-md-3">
<div class="checkbox">
<label><input id="chkPrintAnnotations" type="checkbox" value="">Print Annotations?</label>
</div>
<div class="checkbox">
<label><input id="chkPrintAsGrayscale" type="checkbox" value="">Print As Grayscale?</label>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<label for="lstPrintRotation">Page Sizing:</label>
<select name="lstPrintRotation" id="lstPageSizing" class="form-control">
<option>None</option>
<option>Fit</option>
</select>
</div>
<div class="col-md-3">
<div class="checkbox">
<label><input id="chkAutoCenter" type="checkbox" value="">Auto Center?</label>
</div>
</div>
<div class="col-md-3">
<div class="checkbox">
<label><input id="chkAutoRotate" type="checkbox" value="">Auto Rotate?</label>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<a class="btn btn-success btn-lg pull-right" onclick="javascript:jsWebClientPrint.print('printerName=' + encodeURIComponent($('#lstPrinters').val()) + '&trayName=' + encodeURIComponent($('#lstPrinterTrays').val()) + '&paperName=' + encodeURIComponent($('#lstPrinterPapers').val()) + '&printRotation=' + $('#lstPrintRotation').val() + '&pagesRange=' + encodeURIComponent($('#txtPagesRange').val()) + '&printAnnotations=' + $('#chkPrintAnnotations').prop('checked') + '&printAsGrayscale=' + $('#chkPrintAsGrayscale').prop('checked') + '&printInReverseOrder=' + $('#chkPrintInReverseOrder').prop('checked') + '&manualDuplexPrinting=' + $('#chkManualDuplexPrinting').prop('checked') + '&driverDuplexPrinting=' + ($('#chkDriverDuplexPrinting').prop('disabled') ? 'false' : $('#chkDriverDuplexPrinting').prop('checked')) + '&pageSizing=' + $('#lstPageSizing').val() + '&autoRotate=' + ($('#chkAutoRotate').prop('disabled') ? 'false' : $('#chkAutoRotate').prop('checked')) + '&autoCenter=' + ($('#chkAutoCenter').prop('disabled') ? 'false' : $('#chkAutoCenter').prop('checked')));"><strong>Print PDF...</strong></a>
</div>
</div>
<hr />
<h4>PDF File Sample Preview - <strong>13 Pages</strong></h4>
<iframe id="ifPreview" style="width: 100%; height: 500px;" frameborder="0" src="//docs.google.com/gview?url=http://webclientprint.azurewebsites.net/files/mixed-page-orientation.pdf&embedded=true"></iframe>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var clientPrinters = null;
var wcppGetPrintersTimeout_ms = 60000; //60 sec
var wcppGetPrintersTimeoutStep_ms = 500; //0.5 sec
function wcpGetPrintersOnSuccess() {
$('#spinner').css('visibility', 'hidden');
// Display client installed printers
if (arguments[0].length > 0) {
if (JSON) {
try {
clientPrinters = JSON.parse(arguments[0]);
if (clientPrinters.error) {
alert(clientPrinters.error)
} else {
var options = '';
for (var i = 0; i < clientPrinters.length; i++) {
options += '<option>' + clientPrinters[i].name + '</option>';
}
$('#lstPrinters').html(options);
$('#lstPrinters').focus();
showSelectedPrinterInfo();
}
} catch (e) {
alert(e.message)
}
}
} else {
alert("No printers are installed in your system.");
}
}
function wcpGetPrintersOnFailure() {
$('#spinner').css('visibility', 'hidden');
// Do something if printers cannot be got from the client
alert("No printers are installed in your system.");
}
function showSelectedPrinterInfo() {
// get selected printer index
var idx = $("#lstPrinters")[0].selectedIndex;
// get supported trays
var options = '';
if (clientPrinters[idx].trays) {
for (var i = 0; i < clientPrinters[idx].trays.length; i++) {
options += '<option>' + clientPrinters[idx].trays[i] + '</option>';
}
}
$('#lstPrinterTrays').html(options);
// get supported papers
options = '';
if (clientPrinters[idx].papers) {
for (var i = 0; i < clientPrinters[idx].papers.length; i++) {
options += '<option>' + clientPrinters[idx].papers[i] + '</option>';
}
}
$('#lstPrinterPapers').html(options);
// update duplex option
$('#chkDriverDuplexPrinting').attr('checked', clientPrinters[idx].duplex);
$('#chkDriverDuplexPrinting').attr('disabled', !clientPrinters[idx].duplex);
$('#lblDriverDuplexPrinting').attr('style', clientPrinters[idx].duplex ? '' : 'text-decoration: line-through;');
}
</script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolderScripts" runat="Server">
<%-- Register the WebClientPrint script code --%>
<%=Neodynamic.SDK.Web.WebClientPrint.CreateScript(HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port + "/WebClientPrintAPI.ashx", HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port + "/DemoPrintFilePDFHandler.ashx", HttpContext.Current.Session.SessionID)%>
</asp:Content>