forked from mycurelabs/vue-html-to-paper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
195 lines (193 loc) · 6.62 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.min.js"></script>
<script src="./build/vue-html-to-paper.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://unpkg.com/kidlat-css/css/kidlat.css">
<title>Vue Html To Paper - Vue mixin for html elements printing.</title>
</head>
<body>
<div id="app">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="#">VueHtmlToPaper</a>
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="https://github.com/mycure-inc/vue-html-to-paper">GitHub</span></a>
</li>
</ul>
</nav>
<div class="container">
<div id="printMe" class="row">
<div class="col-xs-12 col-md-10 offset-md-1 pt-5">
<h1 align="center">MYCURE Pets</h1>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>Animal</th>
<th>Name</th>
<th>Power Lvl 0-100</th>
<th>Sound</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cate</td>
<td>Kidlat</td>
<td>97</td>
<td>Miiiiiiiiiyaaaaw!!!</td>
</tr>
<tr>
<td>Doge</td>
<td>Cure</td>
<td>80</td>
<td>Nggggggggggggrraw!!!</td>
</tr>
<tr>
<td>Doge</td>
<td>Pickle</td>
<td>79</td>
<td>Aaaaaaw!!! *high pitch*</td>
</tr>
<tr>
<td>Doge</td>
<td>V3</td>
<td>90</td>
<td>Raaaaw!!! *high pitch*</td>
</tr>
<tr>
<td>Doge</td>
<td>V4</td>
<td>40</td>
<td>Raaaaw!!! *high pitch x3*</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-10 offset-md-1 mb-5">
<h4>Default Global Options</h4>
<pre>{{globalOptions}}</pre>
<button class="btn btn-outline-primary" @click="print">PRINT PORTRAIT</button>
</div>
<div class="col-xs-12 col-md-10 offset-md-1 mb-5">
<h4>With Custom CSS</h4>
<p>With custom local css to override the global options. This will print the table on landscape mode.</p>
<pre>{{localLandScapeOptions}}</pre>
<button class="btn btn-outline-primary" @click="printLandscape">PRINT LANDSCAPE</button>
</div>
<div class="col-xs-12 col-md-10 offset-md-1 mb-5">
<h4>Remove styles</h4>
<button class="btn btn-outline-primary" @click="printNoStyles">PRINT NO STYLES</button>
</div>
<div class="col-xs-12 col-md-10 offset-md-1 mb-5">
<h4>Turn off automatic closing after print</h4>
<button class="btn btn-outline-primary" @click="printAutoCloseOff">PRINT AUTO CLOSE OFF</button>
</div>
<div class="col-xs-12 col-md-10 offset-md-1 mb-5">
<h4>Custom window title</h4>
<p>For customizing the file name.</p>
<button class="btn btn-outline-primary" @click="printCustomWindowTitle">PRINT CUSTOM WINDOW TITLE</button>
</div>
<div class="col-xs-12 col-md-10 offset-md-1 mb-5">
<h4>Callback</h4>
<button class="btn btn-outline-primary" @click="printCallback">PRINT CALLBACK</button>
</div>
</div>
</div>
</div>
<script>
const options = {
name: '_blank',
specs: [
'fullscreen=yes',
'titlebar=yes',
'scrollbars=yes'
],
styles: [
'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css',
'https://unpkg.com/kidlat-css/css/kidlat.css'
],
};
Vue.use(VueHtmlToPaper, options);
var vm = new Vue({
el: '#app',
data () {
return {
globalOptions: {
name: '_blank',
specs: [
'fullscreen=yes',
'titlebar=yes',
'scrollbars=yes'
],
styles: [
'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css',
'https://unpkg.com/kidlat-css/css/kidlat.css'
],
timeout: 1000,
autoClose: true,
windowTitle: window.document.title, // whatever's the window title of the opener
},
localLandScapeOptions: {
styles: [
'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css',
'https://unpkg.com/kidlat-css/css/kidlat.css',
'public/landscape.css', // must be the path of your public folder
]
}
}
},
methods: {
async print () {
await vm.$htmlToPaper('printMe');
console.warn('done');
},
async printLandscape () {
const localOptions = {
styles: [
'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css',
'https://unpkg.com/kidlat-css/css/kidlat.css',
'./landscape.css'
]
};
await vm.$htmlToPaper('printMe', localOptions);
console.warn('done landscape');
},
async printNoStyles () {
const localOptions = {
styles: []
};
await vm.$htmlToPaper('printMe', localOptions);
console.warn('done no styles');
},
async printAutoCloseOff () {
const localOptions = {
autoClose: false,
};
await vm.$htmlToPaper('printMe', localOptions);
console.warn('done');
},
async printCustomWindowTitle () {
const localOptions = {
windowTitle: 'This is custom window title',
};
await vm.$htmlToPaper('printMe', localOptions);
console.warn('done');
},
printCallback () {
vm.$htmlToPaper('printMe', null, () => {
console.warn('done callback');
});
},
},
});
</script>
</body>
</html>