forked from parallax/jsPDF
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_insert_page.html
More file actions
85 lines (67 loc) · 2.17 KB
/
Copy pathtest_insert_page.html
File metadata and controls
85 lines (67 loc) · 2.17 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
<!doctype html>
<!--
/**
* jsPDF Insert Page PlugIn
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
*
* Licensed under the MIT License.
* http://opensource.org/licenses/mit-license
*/
-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Insert/Move/Delete Page Test</title>
<script type="text/javascript" src="../jspdf.js"></script>
<script type="text/javascript" src="test_harness.js"></script>
<script>
pdf_test_harness.onload = function(harness) {
var pdf = new jsPDF('p', 'pt', 'letter');
var textHeight = 16;
var y = 0;
var pad = 5;
var context;
pdf.text("Page 1", 20, y + textHeight);
y += textHeight + pad;
context = pdf.internal.getPageInfo(1).pageContext;
context.data = 'this is page 1';
pdf.addPage();
y=0;
pdf.text("Page 2", 20, y + textHeight);
y += textHeight + pad;
context = pdf.internal.getPageInfo(2).pageContext;
context.data = 'this is page 2';
pdf.insertPage(1);
y=0;
pdf.text("Inserted Page", 20, y + textHeight);
y += textHeight + pad;
context = pdf.internal.getCurrentPageInfo().pageContext;
context.data = 'this is page inserted';
pdf.movePage(3, 2);
pdf.addPage();
pdf.text("Page Delete Me", 20, y + textHeight);
y += textHeight + pad;
pdf.deletePage(pdf.currentPage);
pdf.insertPage(1);
y=0;
pdf.text("Testing Insert Page", 20, y + textHeight);
y += textHeight + pad;
pdf.text("Order should be [inserted page] [page 2] [page 1]", 20, y + textHeight);
y += textHeight + pad;
pdf.text("[page 4] should have been deleted", 20, y + textHeight);
y += textHeight + pad;
pdf.internal.getCurrentPageInfo().pageContext.data = 'This is the title page';
// verify context was moved
pdf.addPage();
for (var i=1; i<=4; i++){
context = pdf.internal.getPageInfo(i).pageContext;
pdf.text("Page " + i, 20, i*30);
pdf.text("context " + context.data, 30, i*30 + 10);
}
return pdf;
}
</script>
</head>
<body style='background-color: silver; margin: 0;'>
</body>
</html>