Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
MrRio committed Sep 28, 2016
2 parents 925dfe8 + 35a9bbd commit 3c73b6b
Show file tree
Hide file tree
Showing 28 changed files with 22,672 additions and 16,161 deletions.
27 changes: 0 additions & 27 deletions bower.json.bak

This file was deleted.

31,145 changes: 15,996 additions & 15,149 deletions dist/jspdf.debug.js

Large diffs are not rendered by default.

319 changes: 162 additions & 157 deletions dist/jspdf.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ <h2><a href="#">Draw example: rectangles / squares</a></h2>

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

doc.save('Test.pdf');</pre>
<a href="javascript:demoRectangles()" class="button">Run Code</a></p></div>
Expand Down
685 changes: 685 additions & 0 deletions examples/canvg_context2d/bar_graph_with_text_and_lines.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/downloadify.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<body onload="load()">
<h1>jsPDF Downloadify Example</h1>

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

<p id="downloadify">
You must have Flash 10 installed to download this file.
Expand Down Expand Up @@ -42,4 +42,4 @@ <h1>jsPDF Downloadify Example</h1>
}
</script>
</body>
</html>
</html>
12 changes: 5 additions & 7 deletions examples/images.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@
<meta name="description" content="">

<script src='js/jquery/jquery-1.7.1.min.js' type='text/javascript'></script>
<script src='../libs/Blob.js/Blob.js' type='text/javascript'></script>
<script src='../libs/FileSaver.js/FileSaver.js' type='text/javascript'></script>
<!--<script src='../libs/Blob.js/Blob.js' type='text/javascript'></script>-->
<!--<script src='../libs/FileSaver.js/FileSaver.js' type='text/javascript'></script>-->

<script src='../libs/png_support/zlib.js' type='text/javascript'></script>
<script src='../libs/png_support/png.js' type='text/javascript'></script>

<script src='../libs/Deflate/deflate.js' type='text/javascript'></script>
<script src='../libs/deflate.js' type='text/javascript'></script>

<script src='../jspdf.js' type='text/javascript'></script>
<script src='../jspdf.plugin.addimage.js' type='text/javascript'></script>
<script src='../jspdf.plugin.png_support.js' type='text/javascript'></script>
<script src='../dist/jspdf.debug.js' type='text/javascript'></script>

<style>
body {
Expand Down Expand Up @@ -156,4 +154,4 @@

</body>

</html>
</html>
12 changes: 12 additions & 0 deletions examples/js/autoprint.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/js/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function demoRectangles() {

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

doc.save('Test.pdf');
}
Expand Down
7 changes: 4 additions & 3 deletions examples/js/editor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion examples/js/font-faces.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,15 @@ doc.text(20, 50, 'This is helvetica bold.');

doc.setFont("courier");
doc.setFontType("bolditalic");
doc.text(20, 60, 'This is courier bolditalic.');
doc.text(20, 60, 'This is courier bolditalic.');

doc.setFont("times");
doc.setFontType("normal");
doc.text(105, 80, 'This is centred text.', null, null, 'center');
doc.text(105, 90, 'And a little bit more underneath it.', null, null, 'center');
doc.text(200, 100, 'This is right aligned text', null, null, 'right');
doc.text(200, 110, 'And some more', null, null, 'right');
doc.text(20, 120, 'Back to left');

doc.text(20, 140, '10 degrees rotated', null, 10);
doc.text(20, 160, '-10 degrees rotated', null, -10);
2 changes: 1 addition & 1 deletion examples/js/font-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ doc.setFontSize(22);
doc.text(20, 20, 'This is a title');

doc.setFontSize(16);
doc.text(20, 30, 'This is some normal sized text underneath.');
doc.text(20, 30, 'This is some normal sized text underneath.');
9 changes: 9 additions & 0 deletions examples/js/images_png.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ <h2>License</h2>
<footer>&copy; 2016 James Hall - <a href="https://parall.ax/pages/privacy-policy">Privacy Policy</a></footer>

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

<!-- Code editor -->

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

<!-- Scripts in development mode -->
<script type="text/javascript" src="dist/jspdf.debug.js"></script>
Expand Down
29 changes: 23 additions & 6 deletions jspdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,7 @@ var jsPDF = (function (global) {
outToPages = false; // switches out() to content

objectNumber = 2;
content_length = 0;
content = [];
offsets = [];
additionalObjects = [];
Expand Down Expand Up @@ -896,7 +897,7 @@ var jsPDF = (function (global) {
putTrailer();
out('>>');
out('startxref');
out(o);
out('' + o);
out('%%EOF');

outToPages = true;
Expand Down Expand Up @@ -1302,16 +1303,13 @@ var jsPDF = (function (global) {
throw new Error('Unrecognized alignment option, use "center" or "right".');
}
prevX = x;
text = da[0] + ") Tj\n";
text = da[0];
for (var i = 1, len = da.length; i < len; i++) {
var delta = maxLineLength - lineWidths[i];
if (align === "center") delta /= 2;
// T* = x-offset leading Td ( text )
text += ( ( left - prevX ) + delta ) + " -" + leading + " Td (" + da[i];
text += ") Tj\n" + ( ( left - prevX ) + delta ) + " -" + leading + " Td (" + da[i];
prevX = left + delta;
if (i < len - 1) {
text += ") Tj\n";
}
}
} else {
text = da.join(") Tj\nT* (");
Expand Down Expand Up @@ -1379,6 +1377,25 @@ var jsPDF = (function (global) {
out('S') // stroke path; necessary for clip to work
};

/**
* This fixes the previous function clip(). Perhaps the 'stroke path' hack was due to the missing 'n' instruction?
* We introduce the fixed version so as to not break API.
* @param fillRule
*/
API.clip_fixed = function (fillRule) {
// Call .clip() after calling drawing ops with a style argument of null
// W is the PDF clipping op
if ('evenodd' === fillRule) {
out('W*');
} else {
out('W');
}
// End the path object without filling or stroking it.
// This operator is a path-painting no-op, used primarily for the side effect of changing the current clipping path
// (see Section 4.4.3, “Clipping Path Operators”)
out('n');
};

/**
* Adds series of curves (straight lines or cubic bezier curves) to canvas, starting at `x`, `y` coordinates.
* All data points in `lines` are relative to last line origin.
Expand Down
10 changes: 10 additions & 0 deletions libs/canvg_context2d/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#About
This fork of canvg provides compatibility with the c2d plugin.
Several changes needed to be made to ensure that our _fake_
canvas is compatible with the canvg rendering engine.

This library was copied from [https://github.com/Flamenco/canvg](https://github.com/Flamenco/canvg).

#Usage
For examples converting HTML pages and SVG elements into PDF using canvg and the context2d plugin,
see the examples in the /examples/canvg_context2d directory.
Loading

0 comments on commit 3c73b6b

Please sign in to comment.