Skip to content

Commit e76f566

Browse files
committed
Merge 'master' into pr/801
2 parents bd60b2f + 5acfc8c commit e76f566

25 files changed

+22626
-16238
lines changed

bower.json.bak

-27
This file was deleted.

dist/jspdf.debug.js

+15,992-15,235
Large diffs are not rendered by default.

dist/jspdf.min.js

+160-162
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/basic.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ <h2><a href="#">Draw example: rectangles / squares</a></h2>
392392

393393
doc.setDrawColor(0);
394394
doc.setFillColor(255, 255, 255);
395-
doc.roundedRect(140, 20, 10, 10, 3, 3, 'FD'); // Black sqaure with rounded corners
395+
doc.roundedRect(140, 20, 10, 10, 3, 3, 'FD'); // Black square with rounded corners
396396

397397
doc.save('Test.pdf');</pre>
398398
<a href="javascript:demoRectangles()" class="button">Run Code</a></p></div>

examples/canvg_context2d/bar_graph_with_text_and_lines.html

+685
Large diffs are not rendered by default.

examples/downloadify.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<body onload="load()">
1313
<h1>jsPDF Downloadify Example</h1>
1414

15-
<p>This is an example of jsPDF using <a href="http://www.downloadify.info/">Downloadify</a>. This works in all major browsers.</p>
15+
<p>This is an example of jsPDF using <a href="https://github.com/dcneiner/Downloadify">Downloadify</a>. This works in all major browsers.</p>
1616

1717
<p id="downloadify">
1818
You must have Flash 10 installed to download this file.
@@ -42,4 +42,4 @@ <h1>jsPDF Downloadify Example</h1>
4242
}
4343
</script>
4444
</body>
45-
</html>
45+
</html>

examples/js/autoprint.js

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/js/basic.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function demoRectangles() {
140140

141141
doc.setDrawColor(0);
142142
doc.setFillColor(255, 255, 255);
143-
doc.roundedRect(140, 20, 10, 10, 3, 3, 'FD'); // Black sqaure with rounded corners
143+
doc.roundedRect(140, 20, 10, 10, 3, 3, 'FD'); // Black square with rounded corners
144144

145145
doc.save('Test.pdf');
146146
}

examples/js/editor.js

+4-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/js/font-faces.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,15 @@ doc.text(20, 50, 'This is helvetica bold.');
1616

1717
doc.setFont("courier");
1818
doc.setFontType("bolditalic");
19-
doc.text(20, 60, 'This is courier bolditalic.');
19+
doc.text(20, 60, 'This is courier bolditalic.');
20+
21+
doc.setFont("times");
22+
doc.setFontType("normal");
23+
doc.text(105, 80, 'This is centred text.', null, null, 'center');
24+
doc.text(105, 90, 'And a little bit more underneath it.', null, null, 'center');
25+
doc.text(200, 100, 'This is right aligned text', null, null, 'right');
26+
doc.text(200, 110, 'And some more', null, null, 'right');
27+
doc.text(20, 120, 'Back to left');
28+
29+
doc.text(20, 140, '10 degrees rotated', null, 10);
30+
doc.text(20, 160, '-10 degrees rotated', null, -10);

examples/js/font-size.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ doc.setFontSize(22);
33
doc.text(20, 20, 'This is a title');
44

55
doc.setFontSize(16);
6-
doc.text(20, 30, 'This is some normal sized text underneath.');
6+
doc.text(20, 30, 'This is some normal sized text underneath.');

index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ <h2>License</h2>
142142
<footer>&copy; 2016 James Hall - <a href="https://parall.ax/pages/privacy-policy">Privacy Policy</a></footer>
143143

144144
<!-- Scripts down here -->
145-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
145+
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
146146
<script src="http://html2canvas.hertzen.com/build/html2canvas.js"></script>
147147

148148
<!-- Code editor -->
149149

150-
<script src="https://cdn.jsdelivr.net/ace/1.1.01/noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
150+
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.5/ace.js" type="text/javascript" charset="utf-8"></script>
151151

152152
<!-- Scripts in development mode -->
153153
<script type="text/javascript" src="dist/jspdf.debug.js"></script>

jspdf.js

+23-6
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,7 @@ var jsPDF = (function (global) {
846846
outToPages = false; // switches out() to content
847847

848848
objectNumber = 2;
849+
content_length = 0;
849850
content = [];
850851
offsets = [];
851852
additionalObjects = [];
@@ -896,7 +897,7 @@ var jsPDF = (function (global) {
896897
putTrailer();
897898
out('>>');
898899
out('startxref');
899-
out(o);
900+
out('' + o);
900901
out('%%EOF');
901902

902903
outToPages = true;
@@ -1302,16 +1303,13 @@ var jsPDF = (function (global) {
13021303
throw new Error('Unrecognized alignment option, use "center" or "right".');
13031304
}
13041305
prevX = x;
1305-
text = da[0] + ") Tj\n";
1306+
text = da[0];
13061307
for (var i = 1, len = da.length; i < len; i++) {
13071308
var delta = maxLineLength - lineWidths[i];
13081309
if (align === "center") delta /= 2;
13091310
// T* = x-offset leading Td ( text )
1310-
text += ( ( left - prevX ) + delta ) + " -" + leading + " Td (" + da[i];
1311+
text += ") Tj\n" + ( ( left - prevX ) + delta ) + " -" + leading + " Td (" + da[i];
13111312
prevX = left + delta;
1312-
if (i < len - 1) {
1313-
text += ") Tj\n";
1314-
}
13151313
}
13161314
} else {
13171315
text = da.join(") Tj\nT* (");
@@ -1379,6 +1377,25 @@ var jsPDF = (function (global) {
13791377
out('S') // stroke path; necessary for clip to work
13801378
};
13811379

1380+
/**
1381+
* This fixes the previous function clip(). Perhaps the 'stroke path' hack was due to the missing 'n' instruction?
1382+
* We introduce the fixed version so as to not break API.
1383+
* @param fillRule
1384+
*/
1385+
API.clip_fixed = function (fillRule) {
1386+
// Call .clip() after calling drawing ops with a style argument of null
1387+
// W is the PDF clipping op
1388+
if ('evenodd' === fillRule) {
1389+
out('W*');
1390+
} else {
1391+
out('W');
1392+
}
1393+
// End the path object without filling or stroking it.
1394+
// This operator is a path-painting no-op, used primarily for the side effect of changing the current clipping path
1395+
// (see Section 4.4.3, “Clipping Path Operators”)
1396+
out('n');
1397+
};
1398+
13821399
/**
13831400
* Adds series of curves (straight lines or cubic bezier curves) to canvas, starting at `x`, `y` coordinates.
13841401
* All data points in `lines` are relative to last line origin.

libs/canvg_context2d/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#About
2+
This fork of canvg provides compatibility with the c2d plugin.
3+
Several changes needed to be made to ensure that our _fake_
4+
canvas is compatible with the canvg rendering engine.
5+
6+
This library was copied from [https://github.com/Flamenco/canvg](https://github.com/Flamenco/canvg).
7+
8+
#Usage
9+
For examples converting HTML pages and SVG elements into PDF using canvg and the context2d plugin,
10+
see the examples in the /examples/canvg_context2d directory.

0 commit comments

Comments
 (0)