Skip to content

Commit 41ec70e

Browse files
committed
Minor tweaks
1 parent c9c84c7 commit 41ec70e

File tree

5 files changed

+134
-93
lines changed

5 files changed

+134
-93
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jspdf",
3-
"version": "1.0.88",
3+
"version": "1.0.104",
44
"homepage": "https://github.com/mrrio/jspdf",
55
"description": "PDF Document creation from JavaScript",
66
"main": "dist/jspdf.min.js",

build.sh

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ options="-m -c --wrap --stats"
99
version="`python -c 'import time;t=time.gmtime(time.time());print("1.%d.%d" % (t[0] - 2014, t[7]))'`"
1010
libs="`find libs/* -maxdepth 2 -type f | grep .js$ | grep -v -E '(\.min|BlobBuilder\.js$|Downloadify|demo|deps|test)'`"
1111
files="jspdf.js jspdf.plugin*js"
12-
commit=`git rev-parse HEAD`
1312
build=`date +%Y-%m-%dT%H:%M`
13+
commit=`git rev-parse --short=10 HEAD`
1414
whoami=`whoami`
1515

1616
# Update submodules
@@ -30,7 +30,7 @@ libs=${libs/$adler1/$adler2}
3030

3131
# Build dist files
3232
cat ${files} ${libs} \
33-
| sed s/\${buildDate}/${build}/ \
33+
| sed s/\${versionID}/${version}-git\ Built\ on\ ${build}/ \
3434
| sed s/\${commitID}/${commit}/ \
3535
| sed "s/\"1\.0\.0-trunk\"/\"${version}-debug ${build}:${whoami}\"/" >${output/min/debug}
3636
uglifyjs ${options} -o ${output} ${files} ${libs}
@@ -45,7 +45,7 @@ for fn in ${files} ${libs}; do
4545

4646
if test "x$fn" = "xjspdf.js"; then
4747
cat ${output}.x \
48-
| sed s/\${buildDate}/${build}/ \
48+
| sed s/\${versionID}/${version}-git\ Built\ on\ ${build}/ \
4949
| sed s/\${commitID}/${commit}/ >> ${output}.tmp
5050
else
5151
cat ${output}.x \
@@ -56,3 +56,32 @@ done
5656
cat ${output} >> ${output}.tmp
5757
cat ${output}.tmp | sed '/^\s*$/d' | sed "s/\"1\.0\.0-trunk\"/\"${version}-git ${build}:${whoami}\"/" > ${output}
5858
rm -f ${output}.tmp ${output}.x $adler2
59+
60+
61+
# Check options
62+
while [ $# -gt 0 ]
63+
do
64+
case "$1" in
65+
-c|-commit)
66+
shift
67+
git_commit="$1"
68+
;;
69+
-p|-push)
70+
git_push=1
71+
;;
72+
*)
73+
break
74+
;;
75+
esac
76+
shift
77+
done
78+
79+
if [ "$git_push" = "1" -a -z "$git_commit" ]; then
80+
git_commit="New dist files."
81+
fi
82+
if [ -n "$git_commit" ]; then
83+
git commit -a -m "$git_commit"
84+
fi
85+
if [ "$git_push" = "1" ]; then
86+
git push
87+
fi

dist/jspdf.debug.js

Lines changed: 76 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @preserve
22
* jsPDF - PDF Document creation from JavaScript
3-
* Version 1.0.0-trunk Built on 2014-03-29T20:16
4-
* Commit c94d9d2735f0ab943c834b20cd58c7a08368b2ed
3+
* Version 1.0.104-git Built on 2014-04-14T04:50
4+
* CommitID 077bd24022
55
*
66
* Copyright (c) 2010-2014 James Hall, https://github.com/MrRio/jsPDF
77
* 2010 Aaron Spike, https://github.com/acspike
@@ -228,7 +228,12 @@ var jsPDF = (function(global) {
228228
out('endstream');
229229
},
230230
putPages = function() {
231-
var n,p,arr,i,deflater,adler32,wPt = pageWidth * k, hPt = pageHeight * k;
231+
var n,p,arr,i,deflater,adler32,wPt = pageWidth * k, hPt = pageHeight * k, adler32cs;
232+
233+
adler32cs = global.adler32cs || jsPDF.adler32cs;
234+
if (compress && typeof adler32cs === 'undefined') {
235+
compress = false;
236+
}
232237

233238
// outToPages = false as set in endDocument(). out() writes to content.
234239

@@ -243,10 +248,6 @@ var jsPDF = (function(global) {
243248
// Page content
244249
p = pages[n].join('\n');
245250
newObject();
246-
var adler32cs = global.adler32cs || jsPDF.adler32cs;
247-
if (compress && typeof adler32cs == 'undefined') {
248-
compress = false;
249-
}
250251
if (compress) {
251252
arr = [];
252253
i = p.length;
@@ -257,17 +258,11 @@ var jsPDF = (function(global) {
257258
deflater = new Deflater(6);
258259
deflater.append(new Uint8Array(arr));
259260
p = deflater.flush();
260-
arr = [
261-
new Uint8Array([120, 156]),
262-
new Uint8Array(p),
263-
new Uint8Array([adler32 & 0xFF, (adler32 >> 8) & 0xFF, (adler32 >> 16) & 0xFF, (adler32 >> 24) & 0xFF])
264-
];
265-
p = '';
266-
for (i in arr) {
267-
if (arr.hasOwnProperty(i)) {
268-
p += String.fromCharCode.apply(null, arr[i]);
269-
}
270-
}
261+
arr = new Uint8Array(p.length + 6);
262+
arr.set(new Uint8Array([120, 156])),
263+
arr.set(p, 2);
264+
arr.set(new Uint8Array([adler32 & 0xFF, (adler32 >> 8) & 0xFF, (adler32 >> 16) & 0xFF, (adler32 >> 24) & 0xFF]), p.length+2);
265+
p = String.fromCharCode.apply(null, arr);
271266
out('<</Length ' + p.length + ' /Filter [/FlateDecode]>>');
272267
} else {
273268
out('<</Length ' + p.length + '>>');
@@ -416,7 +411,7 @@ var jsPDF = (function(global) {
416411
try {
417412
return fn.apply(this, arguments);
418413
} catch (e) {
419-
var stack = e.stack;
414+
var stack = e.stack || '';
420415
if(~stack.indexOf(' at ')) stack = stack.split(" at ")[1];
421416
var m = "Error in function " + stack.split("\n")[0].split('<')[0] + ": " + e.message;
422417
if(global.console) {
@@ -722,7 +717,7 @@ var jsPDF = (function(global) {
722717
} else if (style === 'FD' || style === 'DF') {
723718
op = 'B'; // both
724719
} else if (style === 'f' || style === 'f*' || style === 'B' || style === 'B*') {
725-
/*
720+
/*
726721
Allow direct use of these PDF path-painting operators:
727722
- f fill using nonzero winding number rule
728723
- f* fill using even-odd rule
@@ -788,16 +783,17 @@ var jsPDF = (function(global) {
788783
// @TODO: Add different output options
789784
});
790785

791-
if (unit === 'pt') {
792-
k = 1;
793-
} else if (unit === 'mm') {
794-
k = 72 / 25.4;
795-
} else if (unit === 'cm') {
796-
k = 72 / 2.54;
797-
} else if (unit === 'in') {
798-
k = 72;
799-
} else {
800-
throw('Invalid unit: ' + unit);
786+
switch (unit) {
787+
case 'pt': k = 1; break;
788+
case 'mm': k = 72 / 25.4; break;
789+
case 'cm': k = 72 / 2.54; break;
790+
case 'in': k = 72; break;
791+
case 'px': k = 96 / 72; break;
792+
case 'pc': k = 12; break;
793+
case 'em': k = 12; break;
794+
case 'ex': k = 6; break;
795+
default:
796+
throw ('Invalid unit: ' + unit);
801797
}
802798

803799
// Dimensions are stored as user units and converted to points on output
@@ -1241,11 +1237,11 @@ var jsPDF = (function(global) {
12411237
f2((pageHeight - y) * k),
12421238
'c'
12431239
].join(' '));
1244-
1240+
12451241
if (style !== null) {
12461242
out(getStyle(style));
1247-
}
1248-
1243+
}
1244+
12491245
return this;
12501246
};
12511247

@@ -1521,7 +1517,7 @@ var jsPDF = (function(global) {
15211517
* @name setTextColor
15221518
*/
15231519
API.setTextColor = function(r, g, b) {
1524-
if ((typeof r == 'string') && /^#[0-9A-Fa-f]{6}$/.test(r)) {
1520+
if ((typeof r === 'string') && /^#[0-9A-Fa-f]{6}$/.test(r)) {
15251521
var hex = parseInt(r.substr(1), 16);
15261522
r = (hex >> 16) & 255;
15271523
g = (hex >> 8) & 255;
@@ -1694,7 +1690,7 @@ var jsPDF = (function(global) {
16941690
* pdfdoc.mymethod() // <- !!!!!!
16951691
*/
16961692
jsPDF.API = {events:[]};
1697-
jsPDF.version = "1.0.88-debug 2014-03-29T20:16:diegocr";
1693+
jsPDF.version = "1.0.104-debug 2014-04-14T04:50:diegocr";
16981694

16991695
if (typeof define === 'function') {
17001696
define(function() {
@@ -2826,22 +2822,22 @@ var jsPDF = (function(global) {
28262822

28272823
})(jsPDF.API);
28282824
/** @preserve
2829-
* jsPDF fromHTML plugin. BETA stage. API subject to change. Needs browser, jQuery
2825+
* jsPDF fromHTML plugin. BETA stage. API subject to change. Needs browser
28302826
* Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
28312827
* 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria
28322828
* 2014 Diego Casorran, https://github.com/diegocr
2833-
*
2829+
*
28342830
* Permission is hereby granted, free of charge, to any person obtaining
28352831
* a copy of this software and associated documentation files (the
28362832
* "Software"), to deal in the Software without restriction, including
28372833
* without limitation the rights to use, copy, modify, merge, publish,
28382834
* distribute, sublicense, and/or sell copies of the Software, and to
28392835
* permit persons to whom the Software is furnished to do so, subject to
28402836
* the following conditions:
2841-
*
2837+
*
28422838
* The above copyright notice and this permission notice shall be
28432839
* included in all copies or substantial portions of the Software.
2844-
*
2840+
*
28452841
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28462842
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28472843
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -2944,32 +2940,49 @@ var jsPDF = (function(global) {
29442940
return UnitedNumberMap[css_line_height_string] = 1;
29452941
};
29462942
GetCSS = function(element) {
2947-
var $e, css, tmp;
2948-
$e = $(element);
2943+
var css, tmp, computedCSSElement;
2944+
computedCSSElement = (function(el) {
2945+
var compCSS;
2946+
compCSS = (function(el) {
2947+
if ( document.defaultView && document.defaultView.getComputedStyle ) {
2948+
return document.defaultView.getComputedStyle(el, null);
2949+
} else if ( el.currentStyle ) {
2950+
return el.currentStyle;
2951+
} else {
2952+
return el.style;
2953+
}
2954+
})(el);
2955+
return function(prop) {
2956+
prop = prop.replace(/-\D/g, function(match){
2957+
return match.charAt(1).toUpperCase();
2958+
})
2959+
return compCSS[prop];
2960+
}
2961+
})(element);
29492962
css = {};
29502963
tmp = void 0;
2951-
css["font-family"] = ResolveFont($e.css("font-family")) || "times";
2952-
css["font-style"] = FontStyleMap[$e.css("font-style")] || "normal";
2953-
tmp = FontWeightMap[$e.css("font-weight")] || "normal";
2964+
css["font-family"] = ResolveFont(computedCSSElement("font-family")) || "times";
2965+
css["font-style"] = FontStyleMap[computedCSSElement("font-style")] || "normal";
2966+
tmp = FontWeightMap[computedCSSElement("font-weight")] || "normal";
29542967
if (tmp === "bold") {
29552968
if (css["font-style"] === "normal") {
29562969
css["font-style"] = tmp;
29572970
} else {
29582971
css["font-style"] = tmp + css["font-style"];
29592972
}
29602973
}
2961-
css["font-size"] = ResolveUnitedNumber($e.css("font-size")) || 1;
2962-
css["line-height"] = ResolveUnitedNumber($e.css("line-height")) || 1;
2963-
css["display"] = ($e.css("display") === "inline" ? "inline" : "block");
2974+
css["font-size"] = ResolveUnitedNumber(computedCSSElement("font-size")) || 1;
2975+
css["line-height"] = ResolveUnitedNumber(computedCSSElement("line-height")) || 1;
2976+
css["display"] = (computedCSSElement("display") === "inline" ? "inline" : "block");
29642977
if (css["display"] === "block") {
2965-
css["margin-top"] = ResolveUnitedNumber($e.css("margin-top")) || 0;
2966-
css["margin-bottom"] = ResolveUnitedNumber($e.css("margin-bottom")) || 0;
2967-
css["padding-top"] = ResolveUnitedNumber($e.css("padding-top")) || 0;
2968-
css["padding-bottom"] = ResolveUnitedNumber($e.css("padding-bottom")) || 0;
2969-
css["margin-left"] = ResolveUnitedNumber($e.css("margin-left")) || 0;
2970-
css["margin-right"] = ResolveUnitedNumber($e.css("margin-right")) || 0;
2971-
css["padding-left"] = ResolveUnitedNumber($e.css("padding-left")) || 0;
2972-
css["padding-right"] = ResolveUnitedNumber($e.css("padding-right")) || 0;
2978+
css["margin-top"] = ResolveUnitedNumber(computedCSSElement("margin-top")) || 0;
2979+
css["margin-bottom"] = ResolveUnitedNumber(computedCSSElement("margin-bottom")) || 0;
2980+
css["padding-top"] = ResolveUnitedNumber(computedCSSElement("padding-top")) || 0;
2981+
css["padding-bottom"] = ResolveUnitedNumber(computedCSSElement("padding-bottom")) || 0;
2982+
css["margin-left"] = ResolveUnitedNumber(computedCSSElement("margin-left")) || 0;
2983+
css["margin-right"] = ResolveUnitedNumber(computedCSSElement("margin-right")) || 0;
2984+
css["padding-left"] = ResolveUnitedNumber(computedCSSElement("padding-left")) || 0;
2985+
css["padding-right"] = ResolveUnitedNumber(computedCSSElement("padding-right")) || 0;
29732986
}
29742987
return css;
29752988
};
@@ -3133,9 +3146,13 @@ var jsPDF = (function(global) {
31333146
var $frame, $hiddendiv, framename, visuallyhidden;
31343147
framename = "jsPDFhtmlText" + Date.now().toString() + (Math.random() * 1000).toFixed(0);
31353148
visuallyhidden = "position: absolute !important;" + "clip: rect(1px 1px 1px 1px); /* IE6, IE7 */" + "clip: rect(1px, 1px, 1px, 1px);" + "padding:0 !important;" + "border:0 !important;" + "height: 1px !important;" + "width: 1px !important; " + "top:auto;" + "left:-100px;" + "overflow: hidden;";
3136-
$hiddendiv = $("<div style=\"" + visuallyhidden + "\">" + "<iframe style=\"height:1px;width:1px\" name=\"" + framename + "\" />" + "</div>").appendTo(document.body);
3149+
$hiddendiv = document.createElement('div');
3150+
$hiddendiv.style.cssText = visuallyhidden;
3151+
$hiddendiv.innerHTML = "<iframe style=\"height:1px;width:1px\" name=\"" + framename + "\" />";
3152+
document.body.appendChild($hiddendiv);
31373153
$frame = window.frames[framename];
3138-
return $($frame.document.body).html(element)[0];
3154+
$frame.document.body.innerHTML = element;
3155+
return $frame.document.body;
31393156
})(element.replace(/<\/?script[^>]*?>/gi,''));
31403157
}
31413158
var r = new Renderer(pdf, x, y, settings);
@@ -3314,15 +3331,15 @@ var jsPDF = (function(global) {
33143331
normal: 1
33153332
/*
33163333
Converts HTML-formatted text into formatted PDF text.
3317-
3334+
33183335
Notes:
33193336
2012-07-18
33203337
Plugin relies on having browser, DOM around. The HTML is pushed into dom and traversed.
33213338
Plugin relies on jQuery for CSS extraction.
33223339
Targeting HTML output from Markdown templating, which is a very simple
33233340
markup - div, span, em, strong, p. No br-based paragraph separation supported explicitly (but still may work.)
33243341
Images, tables are NOT supported.
3325-
3342+
33263343
@public
33273344
@function
33283345
@param HTML {String or DOM Element} HTML-formatted text, or pointer to DOM element that is to be rendered into PDF.

dist/jspdf.min.js

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

0 commit comments

Comments
 (0)