Skip to content

Commit fc841d0

Browse files
committed
Fix html2pdf - start with examples
1 parent c01f6b5 commit fc841d0

File tree

8 files changed

+104
-86
lines changed

8 files changed

+104
-86
lines changed

dist/jspdf.debug.js

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
/** @preserve
1414
* jsPDF - PDF Document creation from JavaScript
15-
* Version 1.3.0 Built on 2016-09-28T10:52:40.410Z
16-
* CommitID a434267220
15+
* Version 1.3.0 Built on 2016-09-28T17:23:20.924Z
16+
* CommitID c01f6b51de
1717
*
1818
* Copyright (c) 2010-2014 James Hall <[email protected]>, https://github.com/MrRio/jsPDF
1919
* 2010 Aaron Spike, https://github.com/acspike
@@ -2026,7 +2026,7 @@
20262026
* pdfdoc.mymethod() // <- !!!!!!
20272027
*/
20282028
jsPDF.API = { events: [] };
2029-
jsPDF.version = "1.3.0 2016-09-28T10:52:40.410Z:jameshall";
2029+
jsPDF.version = "1.3.0 2016-09-28T17:23:20.924Z:jameshall";
20302030

20312031
if (typeof define === 'function' && define.amd) {
20322032
define('jsPDF', function () {
@@ -2588,25 +2588,51 @@ Q\n";
25882588
var DotRadius = AcroForm.Appearance.internal.getWidth(formObject) <= AcroForm.Appearance.internal.getHeight(formObject) ? AcroForm.Appearance.internal.getWidth(formObject) / 4 : AcroForm.Appearance.internal.getHeight(formObject) / 4;
25892589
// The Borderpadding...
25902590
DotRadius *= 0.9;
2591-
var c = AcroForm.Appearance.internal.Bezier_C;
2591+
// Save results for later use; no need to waste processor ticks on doing math
2592+
var k = DotRadius * 2;
2593+
// var c = AcroForm.Appearance.internal.Bezier_C;
2594+
var kc = k * AcroForm.Appearance.internal.Bezier_C;
2595+
var dc = DotRadius * AcroForm.Appearance.internal.Bezier_C;
2596+
// stream += "0.749023 g\n\
2597+
// q\n\
2598+
// 1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\
2599+
// " + DotRadius * 2 + " 0 m\n\
2600+
// " + DotRadius * 2 + " " + DotRadius * 2 * c + " " + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 " + DotRadius * 2 + " c\n\
2601+
// -" + DotRadius * 2 * c + " " + DotRadius * 2 + " -" + DotRadius * 2 + " " + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 c\n\
2602+
// -" + DotRadius * 2 + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 -" + DotRadius * 2 + " c\n\
2603+
// " + DotRadius * 2 * c + " -" + DotRadius * 2 + " " + DotRadius * 2 + " -" + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 c\n\
2604+
// f\n\
2605+
// Q\n\
2606+
// 0 g\n\
2607+
// q\n\
2608+
// 1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\
2609+
// " + DotRadius + " 0 m\n\
2610+
// " + DotRadius + " " + DotRadius * c + " " + DotRadius * c + " " + DotRadius + " 0 " + DotRadius + " c\n\
2611+
// -" + DotRadius * c + " " + DotRadius + " -" + DotRadius + " " + DotRadius * c + " -" + DotRadius + " 0 c\n\
2612+
// -" + DotRadius + " -" + DotRadius * c + " -" + DotRadius * c + " -" + DotRadius + " 0 -" + DotRadius + " c\n\
2613+
// " + DotRadius * c + " -" + DotRadius + " " + DotRadius + " -" + DotRadius * c + " " + DotRadius + " 0 c\n\
2614+
// f\n\
2615+
// Q\n";
2616+
2617+
// FASTER VERSION with less processor ticks spent on math operations
25922618
stream += "0.749023 g\n\
25932619
q\n\
25942620
1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\
2595-
" + DotRadius * 2 + " 0 m\n\
2596-
" + DotRadius * 2 + " " + DotRadius * 2 * c + " " + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 " + DotRadius * 2 + " c\n\
2597-
-" + DotRadius * 2 * c + " " + DotRadius * 2 + " -" + DotRadius * 2 + " " + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 c\n\
2598-
-" + DotRadius * 2 + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 -" + DotRadius * 2 + " c\n\
2599-
" + DotRadius * 2 * c + " -" + DotRadius * 2 + " " + DotRadius * 2 + " -" + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 c\n\
2621+
" + k + " 0 m\n\
2622+
" + k + " " + kc + " " + kc + " " + k + " 0 " + k + " c\n\
2623+
-" + kc + " " + k + " -" + k + " " + kc + " -" + k + " 0 c\n\
2624+
-" + k + " -" + kc + " -" + kc + " -" + k + " 0 -" + k + " c\n\
2625+
" + kc + " -" + k + " " + k + " -" + kc + " " + k + " 0 c\n\
26002626
f\n\
26012627
Q\n\
26022628
0 g\n\
26032629
q\n\
26042630
1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\
26052631
" + DotRadius + " 0 m\n\
2606-
" + DotRadius + " " + DotRadius * c + " " + DotRadius * c + " " + DotRadius + " 0 " + DotRadius + " c\n\
2607-
-" + DotRadius * c + " " + DotRadius + " -" + DotRadius + " " + DotRadius * c + " -" + DotRadius + " 0 c\n\
2608-
-" + DotRadius + " -" + DotRadius * c + " -" + DotRadius * c + " -" + DotRadius + " 0 -" + DotRadius + " c\n\
2609-
" + DotRadius * c + " -" + DotRadius + " " + DotRadius + " -" + DotRadius * c + " " + DotRadius + " 0 c\n\
2632+
" + DotRadius + " " + dc + " " + dc + " " + DotRadius + " 0 " + DotRadius + " c\n\
2633+
-" + dc + " " + DotRadius + " -" + DotRadius + " " + dc + " -" + DotRadius + " 0 c\n\
2634+
-" + DotRadius + " -" + dc + " -" + dc + " -" + DotRadius + " 0 -" + DotRadius + " c\n\
2635+
" + dc + " -" + DotRadius + " " + DotRadius + " -" + dc + " " + DotRadius + " 0 c\n\
26102636
f\n\
26112637
Q\n";
26122638
xobj.stream = stream;
@@ -2618,15 +2644,30 @@ Q\n";
26182644
var DotRadius = AcroForm.Appearance.internal.getWidth(formObject) <= AcroForm.Appearance.internal.getHeight(formObject) ? AcroForm.Appearance.internal.getWidth(formObject) / 4 : AcroForm.Appearance.internal.getHeight(formObject) / 4;
26192645
// The Borderpadding...
26202646
DotRadius *= 0.9;
2621-
var c = AcroForm.Appearance.internal.Bezier_C;
2647+
// Save results for later use; no need to waste processor ticks on doing math
2648+
var k = DotRadius * 2;
2649+
// var c = AcroForm.Appearance.internal.Bezier_C;
2650+
var kc = k * AcroForm.Appearance.internal.Bezier_C;
2651+
// stream += "0.749023 g\n\
2652+
// q\n\
2653+
// 1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\
2654+
// " + DotRadius * 2 + " 0 m\n\
2655+
// " + DotRadius * 2 + " " + DotRadius * 2 * c + " " + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 " + DotRadius * 2 + " c\n\
2656+
// -" + DotRadius * 2 * c + " " + DotRadius * 2 + " -" + DotRadius * 2 + " " + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 c\n\
2657+
// -" + DotRadius * 2 + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 -" + DotRadius * 2 + " c\n\
2658+
// " + DotRadius * 2 * c + " -" + DotRadius * 2 + " " + DotRadius * 2 + " -" + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 c\n\
2659+
// f\n\
2660+
// Q\n";
2661+
2662+
// FASTER VERSION with less processor ticks spent on math operations
26222663
stream += "0.749023 g\n\
26232664
q\n\
26242665
1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\
2625-
" + DotRadius * 2 + " 0 m\n\
2626-
" + DotRadius * 2 + " " + DotRadius * 2 * c + " " + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 " + DotRadius * 2 + " c\n\
2627-
-" + DotRadius * 2 * c + " " + DotRadius * 2 + " -" + DotRadius * 2 + " " + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 c\n\
2628-
-" + DotRadius * 2 + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 -" + DotRadius * 2 + " c\n\
2629-
" + DotRadius * 2 * c + " -" + DotRadius * 2 + " " + DotRadius * 2 + " -" + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 c\n\
2666+
" + k + " 0 m\n\
2667+
" + k + " " + kc + " " + kc + " " + k + " 0 " + k + " c\n\
2668+
-" + kc + " " + k + " -" + k + " " + kc + " -" + k + " 0 c\n\
2669+
-" + k + " -" + kc + " -" + kc + " -" + k + " 0 -" + k + " c\n\
2670+
" + kc + " -" + k + " " + k + " -" + kc + " " + k + " 0 c\n\
26302671
f\n\
26312672
Q\n";
26322673
xobj.stream = stream;

dist/jspdf.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/html2pdf/lists.html

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ <h2>Not Implemented</h2>
3434
armenian
3535
cjk-ideographic
3636
decimal-leading-zero
37-
georgian
37+
georgian
3838
hebrew
3939
hiragana
4040
hiragana-iroha
@@ -43,33 +43,29 @@ <h2>Not Implemented</h2>
4343
</pre>
4444
</div>
4545

46-
<script src='../../libs/require/require.js'></script>
46+
<script src='../../../dist/jspdf.debug.js'></script>
47+
<script src='../../libs/html2pdf.js'></script>
4748

4849
<script>
49-
require_baseUrl_override = '../..';
50-
require(['../../libs/require/config'], function(){
51-
require(['html2pdf'], function(){
52-
50+
5351
var pdf = new jsPDF('p', 'pt', 'letter');
5452
var canvas = pdf.canvas;
5553
canvas.height = 72 * 11;
5654
canvas.width=72 * 8.5;;
5755
// var width = 400;
58-
59-
html2pdf(document.body, pdf, function(canvas) {
56+
57+
html2pdf(document.body, pdf, function(canvas) {
6058
var iframe = document.createElement('iframe');
6159
iframe.setAttribute('style','position:absolute;right:0; top:0; bottom:0; height:100%; width:500px');
6260
document.body.appendChild(iframe);
6361
iframe.src = pdf.output('datauristring');
64-
62+
6563
//var div = document.createElement('pre');
6664
//div.innerText=pdf.output();
6765
//document.body.appendChild(div);
6866
}
6967
);
70-
71-
}); // require
72-
}); // require
68+
7369
</script>
7470
</body>
7571
</html>

examples/html2pdf/page_break.html

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,23 @@ <h1 style='page-break-before: always'>Text</h1>
3535

3636
</div>
3737

38-
<script src='../../libs/require/require.js'></script>
39-
38+
<script src='../../../dist/jspdf.debug.js'></script>
39+
<script src='../../libs/html2pdf.js'></script>
4040
<script>
41-
require_baseUrl_override = '../..';
42-
require(['../../libs/require/config'], function(){
43-
require(['html2pdf'], function(){
41+
4442

4543
var pdf = new jsPDF('p', 'pt', 'letter');
4644
pdf.canvas.height = 72 * 11;
4745
pdf.canvas.width = 72 * 8.5;
48-
46+
4947
//html2pdf(document.documentElement.innerHTML, pdf, function(pdf){
5048
html2pdf(document.body, pdf, function(pdf){
5149
var iframe = document.createElement('iframe');
5250
iframe.setAttribute('style','position:absolute;right:0; top:0; bottom:0; height:100%; width:500px');
5351
document.body.appendChild(iframe);
5452
iframe.src = pdf.output('datauristring');
5553
});
56-
57-
}); // require
58-
}); // require
54+
5955
</script>
6056
</body>
6157
</html>

examples/html2pdf/pdf.html

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,34 +153,28 @@ <h1>sing to me, erbarme dich</h1>
153153
This is a nonsensical document, but syntactically valid HTML 4.0. All 100% conformant CSS1 agents should be able to render the document elements above this paragraph <b>indistinguishably</b> (to the pixel) from this reference rendering, (except font rasterization and form widgets). All discrepancies should be traceable to CSS1 implementation shortcomings. Once you have finished evaluating this test, you can return to the <A HREF="sec5526c.htm" style="text-decoration: none">parent page</A>.
154154
</p>
155155

156-
<script src='../../libs/require/require.js'></script>
157-
156+
<script src='../../../dist/jspdf.debug.js'></script>
157+
<script src='../../libs/html2pdf.js'></script>
158158
<script>
159-
require_baseUrl_override = '../..';
160-
require(['../../libs/require/config'], function(){
161-
require(['html2pdf'], function(){
162-
159+
163160
var pdf = new jsPDF('p', 'pt', 'letter');
164161
var canvas = pdf.canvas;
165-
162+
166163
canvas.width=8.5*72;
167-
164+
168165
html2canvas(document.body, {
169166
canvas:canvas,
170-
onrendered: function(canvas) {
167+
onrendered: function(canvas) {
171168
var iframe = document.createElement('iframe');
172169
iframe.setAttribute('style','position:absolute;right:0; top:0; bottom:0; height:100%; width:500px');
173170
document.body.appendChild(iframe);
174171
iframe.src = pdf.output('datauristring');
175-
172+
176173
//var div = document.createElement('pre');
177174
//div.innerText=pdf.output();
178175
//document.body.appendChild(div);
179176
}
180177
});
181-
182-
}); // require
183-
}); // require
184178
</script>
185179
</body>
186180
</html>

examples/html2pdf/pdf2.html

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,36 +58,33 @@ <h2>More content</h2>
5858
</div>
5959
</div>
6060

61-
<script src='../../libs/require/require.js'></script>
61+
62+
<script src='../../../dist/jspdf.debug.js'></script>
63+
<script src='../../libs/html2pdf.js'></script>
6264

6365
<script>
64-
require_baseUrl_override = '../..';
65-
require(['../../libs/require/config'], function(){
66-
require(['html2pdf'], function(){
67-
66+
67+
6868
var pdf = new jsPDF('p', 'pt', 'letter');
6969
var canvas = pdf.canvas;
70-
70+
7171
var width = 600;
7272
//canvas.width=8.5*72;
7373
document.body.style.width=width + "px";
74-
74+
7575
html2canvas(document.body, {
7676
canvas:canvas,
77-
onrendered: function(canvas) {
77+
onrendered: function(canvas) {
7878
var iframe = document.createElement('iframe');
7979
iframe.setAttribute('style', 'position:absolute;top:0;right:0;height:100%; width:600px');
8080
document.body.appendChild(iframe);
8181
iframe.src = pdf.output('datauristring');
82-
82+
8383
//var div = document.createElement('pre');
8484
//div.innerText=pdf.output();
8585
//document.body.appendChild(div);
8686
}
8787
});
88-
89-
});
90-
});
9188
</script>
9289
</body>
9390
</html>

examples/html2pdf/showcase.html

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,33 +65,32 @@ <h2>Font Size</h2>
6565

6666
</div>
6767

68-
<script src='../../libs/require/require.js'></script>
68+
69+
<script src='../../../dist/jspdf.debug.js'></script>
70+
<script src='../../libs/html2pdf.js'></script>
6971

7072
<script>
7173
require_baseUrl_override = '../..';
72-
require(['../../libs/require/config'], function(){
73-
require(['html2pdf'], function(){
74+
7475

7576
var pdf = new jsPDF('p', 'pt', 'letter');
7677
var canvas = pdf.canvas;
7778
canvas.height = 72 * 11;
7879
canvas.width=72 * 8.5;;
7980
// var width = 400;
80-
81-
html2pdf(document.body, pdf, function(pdf) {
81+
82+
html2pdf(document.body, pdf, function(pdf) {
8283
var iframe = document.createElement('iframe');
8384
iframe.setAttribute('style','position:absolute;right:0; top:0; bottom:0; height:100%; width:500px');
8485
document.body.appendChild(iframe);
8586
iframe.src = pdf.output('datauristring');
86-
87+
8788
//var div = document.createElement('pre');
8889
//div.innerText=pdf.output();
8990
//document.body.appendChild(div);
9091
}
9192
);
92-
93-
}); // require
94-
}); // require
93+
9594
</script>
9695
</body>
9796
</html>

examples/html2pdf/showcase_supported_html.html

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ <h1 class='page-break'>
9999
<h1>Images</h1>
100100
Images are subject to CORS restrictions an may only show up in a production environment.
101101
When testing, we start Chrome with the '--allow-file-access-from-files' flag...
102-
102+
103103
<img src="images/favicon.png" height="100" />
104-
104+
105105
<h1 class='page-break'>Lists</h1>
106106
<table id='table-list-styles'>
107107
<tr>
@@ -200,26 +200,21 @@ <h2>External</h2>
200200
</p>
201201
</div>
202202

203-
<script src='../../libs/require/require.js'></script>
203+
<script src='../../../dist/jspdf.debug.js'></script>
204+
<script src='../../libs/html2pdf.js'></script>
204205

205206
<script>
206-
require_baseUrl_override = '../..';
207-
require(['../../libs/require/config'], function(){
208-
require(['html2pdf'], function(){
209-
210207
var pdf = new jsPDF('p', 'pt', 'letter');
211208
pdf.canvas.height = 72 * 11;
212209
pdf.canvas.width = 72 * 8.5;
213-
210+
214211
//html2pdf(document.documentElement.innerHTML, pdf, function(pdf){
215212
html2pdf(document.body, pdf, function(pdf){
216213
var iframe = document.createElement('iframe');
217214
iframe.setAttribute('style','position:absolute;right:0; top:0; bottom:0; height:100%; width:500px');
218215
document.body.appendChild(iframe);
219216
iframe.src = pdf.output('datauristring');
220217
});
221-
}); // require
222-
}); // require
223218
</script>
224219
</body>
225220
</html>

0 commit comments

Comments
 (0)