1
1
/** @preserve
2
2
* 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
5
5
*
6
6
* Copyright (c) 2010-2014 James Hall, https://github.com/MrRio/jsPDF
7
7
* 2010 Aaron Spike, https://github.com/acspike
@@ -228,7 +228,12 @@ var jsPDF = (function(global) {
228
228
out ( 'endstream' ) ;
229
229
} ,
230
230
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
+ }
232
237
233
238
// outToPages = false as set in endDocument(). out() writes to content.
234
239
@@ -243,10 +248,6 @@ var jsPDF = (function(global) {
243
248
// Page content
244
249
p = pages [ n ] . join ( '\n' ) ;
245
250
newObject ( ) ;
246
- var adler32cs = global . adler32cs || jsPDF . adler32cs ;
247
- if ( compress && typeof adler32cs == 'undefined' ) {
248
- compress = false ;
249
- }
250
251
if ( compress ) {
251
252
arr = [ ] ;
252
253
i = p . length ;
@@ -257,17 +258,11 @@ var jsPDF = (function(global) {
257
258
deflater = new Deflater ( 6 ) ;
258
259
deflater . append ( new Uint8Array ( arr ) ) ;
259
260
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 ) ;
271
266
out ( '<</Length ' + p . length + ' /Filter [/FlateDecode]>>' ) ;
272
267
} else {
273
268
out ( '<</Length ' + p . length + '>>' ) ;
@@ -416,7 +411,7 @@ var jsPDF = (function(global) {
416
411
try {
417
412
return fn . apply ( this , arguments ) ;
418
413
} catch ( e ) {
419
- var stack = e . stack ;
414
+ var stack = e . stack || '' ;
420
415
if ( ~ stack . indexOf ( ' at ' ) ) stack = stack . split ( " at " ) [ 1 ] ;
421
416
var m = "Error in function " + stack . split ( "\n" ) [ 0 ] . split ( '<' ) [ 0 ] + ": " + e . message ;
422
417
if ( global . console ) {
@@ -722,7 +717,7 @@ var jsPDF = (function(global) {
722
717
} else if ( style === 'FD' || style === 'DF' ) {
723
718
op = 'B' ; // both
724
719
} else if ( style === 'f' || style === 'f*' || style === 'B' || style === 'B*' ) {
725
- /*
720
+ /*
726
721
Allow direct use of these PDF path-painting operators:
727
722
- f fill using nonzero winding number rule
728
723
- f* fill using even-odd rule
@@ -788,16 +783,17 @@ var jsPDF = (function(global) {
788
783
// @TODO : Add different output options
789
784
} ) ;
790
785
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 ) ;
801
797
}
802
798
803
799
// Dimensions are stored as user units and converted to points on output
@@ -1241,11 +1237,11 @@ var jsPDF = (function(global) {
1241
1237
f2 ( ( pageHeight - y ) * k ) ,
1242
1238
'c'
1243
1239
] . join ( ' ' ) ) ;
1244
-
1240
+
1245
1241
if ( style !== null ) {
1246
1242
out ( getStyle ( style ) ) ;
1247
- }
1248
-
1243
+ }
1244
+
1249
1245
return this ;
1250
1246
} ;
1251
1247
@@ -1521,7 +1517,7 @@ var jsPDF = (function(global) {
1521
1517
* @name setTextColor
1522
1518
*/
1523
1519
API . setTextColor = function ( r , g , b ) {
1524
- if ( ( typeof r == 'string' ) && / ^ # [ 0 - 9 A - F a - f ] { 6 } $ / . test ( r ) ) {
1520
+ if ( ( typeof r === 'string' ) && / ^ # [ 0 - 9 A - F a - f ] { 6 } $ / . test ( r ) ) {
1525
1521
var hex = parseInt ( r . substr ( 1 ) , 16 ) ;
1526
1522
r = ( hex >> 16 ) & 255 ;
1527
1523
g = ( hex >> 8 ) & 255 ;
@@ -1694,7 +1690,7 @@ var jsPDF = (function(global) {
1694
1690
* pdfdoc.mymethod() // <- !!!!!!
1695
1691
*/
1696
1692
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" ;
1698
1694
1699
1695
if ( typeof define === 'function' ) {
1700
1696
define ( function ( ) {
@@ -2826,22 +2822,22 @@ var jsPDF = (function(global) {
2826
2822
2827
2823
} ) ( jsPDF . API ) ;
2828
2824
/** @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
2830
2826
* Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
2831
2827
* 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria
2832
2828
* 2014 Diego Casorran, https://github.com/diegocr
2833
- *
2829
+ *
2834
2830
* Permission is hereby granted, free of charge, to any person obtaining
2835
2831
* a copy of this software and associated documentation files (the
2836
2832
* "Software"), to deal in the Software without restriction, including
2837
2833
* without limitation the rights to use, copy, modify, merge, publish,
2838
2834
* distribute, sublicense, and/or sell copies of the Software, and to
2839
2835
* permit persons to whom the Software is furnished to do so, subject to
2840
2836
* the following conditions:
2841
- *
2837
+ *
2842
2838
* The above copyright notice and this permission notice shall be
2843
2839
* included in all copies or substantial portions of the Software.
2844
- *
2840
+ *
2845
2841
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2846
2842
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2847
2843
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -2944,32 +2940,49 @@ var jsPDF = (function(global) {
2944
2940
return UnitedNumberMap [ css_line_height_string ] = 1 ;
2945
2941
} ;
2946
2942
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 ) ;
2949
2962
css = { } ;
2950
2963
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" ;
2954
2967
if ( tmp === "bold" ) {
2955
2968
if ( css [ "font-style" ] === "normal" ) {
2956
2969
css [ "font-style" ] = tmp ;
2957
2970
} else {
2958
2971
css [ "font-style" ] = tmp + css [ "font-style" ] ;
2959
2972
}
2960
2973
}
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" ) ;
2964
2977
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 ;
2973
2986
}
2974
2987
return css ;
2975
2988
} ;
@@ -3133,9 +3146,13 @@ var jsPDF = (function(global) {
3133
3146
var $frame , $hiddendiv , framename , visuallyhidden ;
3134
3147
framename = "jsPDFhtmlText" + Date . now ( ) . toString ( ) + ( Math . random ( ) * 1000 ) . toFixed ( 0 ) ;
3135
3148
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 ) ;
3137
3153
$frame = window . frames [ framename ] ;
3138
- return $ ( $frame . document . body ) . html ( element ) [ 0 ] ;
3154
+ $frame . document . body . innerHTML = element ;
3155
+ return $frame . document . body ;
3139
3156
} ) ( element . replace ( / < \/ ? s c r i p t [ ^ > ] * ?> / gi, '' ) ) ;
3140
3157
}
3141
3158
var r = new Renderer ( pdf , x , y , settings ) ;
@@ -3314,15 +3331,15 @@ var jsPDF = (function(global) {
3314
3331
normal : 1
3315
3332
/*
3316
3333
Converts HTML-formatted text into formatted PDF text.
3317
-
3334
+
3318
3335
Notes:
3319
3336
2012-07-18
3320
3337
Plugin relies on having browser, DOM around. The HTML is pushed into dom and traversed.
3321
3338
Plugin relies on jQuery for CSS extraction.
3322
3339
Targeting HTML output from Markdown templating, which is a very simple
3323
3340
markup - div, span, em, strong, p. No br-based paragraph separation supported explicitly (but still may work.)
3324
3341
Images, tables are NOT supported.
3325
-
3342
+
3326
3343
@public
3327
3344
@function
3328
3345
@param HTML {String or DOM Element} HTML-formatted text, or pointer to DOM element that is to be rendered into PDF.
0 commit comments