12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <!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>
|