Repository navigation
Expand file tree
/
Copy pathtest.html
More file actions
66 lines (61 loc) · 1.37 KB
/
Copy pathtest.html
File metadata and controls
66 lines (61 loc) · 1.37 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
<html>
<script src='./dist/print.min.js'></script>
<script type='text/javascript'>
function printPdf() {
printJS('/test.pdf');
}
function printHtml() {
printJS({
printable: 'test',
type: 'html'
});
}
function printHtmlCustom() {
const css = `
@page {
margin: 0
}
`
printJS({
printable: 'test',
type: 'html',
css: css,
scanStyles: false
});
}
function printJson() {
let data = [
{
test1: 'Test1 string',
test2: {
a: 'Test2 object, a property',
}
},
{
test1: 'more Test1 string',
test2: {
a: 'more Test2 object, a property',
}
}
]
printJS({printable: data, properties: ['test1', 'test2.a'], type: 'json'})
}
</script>
<body>
<section id="test" class="test">
<h1>Print.js Test Page</h1>
<button onClick='printPdf();'>
Print PDF
</button>
<button onClick='printHtml();'>
Print HTML
</button>
<button onClick='printHtmlCustom();'>
Print HTML with custom css
</button>
<button onClick='printJson();'>
Print JSON
</button>
</section>
</body>
</html>