Skip to content

Commit

Permalink
New dist files.
Browse files Browse the repository at this point in the history
  • Loading branch information
diegocr committed Jun 27, 2014
1 parent 78eac71 commit da257c2
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 21 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jspdf",
"version": "1.0.150",
"version": "1.0.178",
"homepage": "https://github.com/mrrio/jspdf",
"description": "PDF Document creation from JavaScript",
"main": "dist/jspdf.min.js",
Expand Down
159 changes: 147 additions & 12 deletions dist/jspdf.debug.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @preserve
* jsPDF - PDF Document creation from JavaScript
* Version 1.0.150-git Built on 2014-05-30T00:40
* CommitID dcbc9fcb9b
* Version 1.0.178-git Built on 2014-06-27T15:34
* CommitID 78eac7128d
*
* Copyright (c) 2010-2014 James Hall, https://github.com/MrRio/jsPDF
* 2010 Aaron Spike, https://github.com/acspike
Expand Down Expand Up @@ -1697,7 +1697,7 @@ var jsPDF = (function(global) {
* pdfdoc.mymethod() // <- !!!!!!
*/
jsPDF.API = {events:[]};
jsPDF.version = "1.0.150-debug 2014-05-30T00:40:diegocr";
jsPDF.version = "1.0.178-debug 2014-06-27T15:34:diegocr";

if (typeof define === 'function' && define.amd) {
define(function() {
Expand Down Expand Up @@ -2925,6 +2925,8 @@ var jsPDF = (function(global) {
FontNameDB,
FontStyleMap,
FontWeightMap,
FloatMap,
ClearMap,
GetCSS,
PurgeWhiteSpace,
Renderer,
Expand Down Expand Up @@ -2993,6 +2995,8 @@ var jsPDF = (function(global) {
this.x = x;
this.y = y;
this.settings = settings;
//list of functions which are called after each element-rendering process
this.watchFunctions = [];
this.init();
return this;
};
Expand Down Expand Up @@ -3100,6 +3104,9 @@ var jsPDF = (function(global) {
css["padding-left"] = ResolveUnitedNumber(computedCSSElement("padding-left")) || 0;
css["padding-right"] = ResolveUnitedNumber(computedCSSElement("padding-right")) || 0;
}
//float and clearing of floats
css["float"] = FloatMap[computedCSSElement("cssFloat")] || "none";
css["clear"] = ClearMap[computedCSSElement("clear")] || "none";
return css;
};
elementHandledElsewhere = function (element, renderer, elementHandlers) {
Expand Down Expand Up @@ -3215,6 +3222,9 @@ var jsPDF = (function(global) {
while (i < l) {
cn = cns[i];
if (typeof cn === "object") {

//execute all watcher functions to e.g. reset floating
renderer.executeWatchFunctions(cn);

/*** HEADER rendering **/
if (cn.nodeType === 1 && cn.nodeName === 'HEADER') {
Expand All @@ -3239,14 +3249,74 @@ var jsPDF = (function(global) {
renderer.pdf.addPage();
renderer.y = renderer.pdf.margins_doc.top;
}

} else if (cn.nodeType === 1 && !SkipNode[cn.nodeName]) {
/*** IMAGE RENDERING ***/
if (cn.nodeName === "IMG" && images[cn.getAttribute("src")]) {
if ((renderer.pdf.internal.pageSize.height - renderer.pdf.margins_doc.bottom < renderer.y + cn.height) && (renderer.y > renderer.pdf.margins_doc.top)) {
renderer.pdf.addPage();
renderer.y = renderer.pdf.margins_doc.top;
//check if we have to set back some values due to e.g. header rendering for new page
renderer.executeWatchFunctions(cn);
}

var imagesCSS = GetCSS(cn);
var imageX = renderer.x;
//if float is set to right, move the image to the right border
if (imagesCSS['float'] !== undefined && imagesCSS['float'] === 'right') {
imageX += renderer.settings.width-cn.width;
}
renderer.pdf.addImage(images[cn.getAttribute("src")], renderer.x, renderer.y, cn.width, cn.height);
renderer.y += cn.height;

renderer.pdf.addImage(images[cn.getAttribute("src")], imageX, renderer.y, cn.width, cn.height);
//if the float prop is specified we have to float the text around the image
if (imagesCSS['float'] !== undefined) {
if (imagesCSS['float'] === 'right' || imagesCSS['float'] === 'left') {

//add functiont to set back coordinates after image rendering
renderer.watchFunctions.push((function(diffX , thresholdY, diffWidth, el) {
//undo drawing box adaptions which were set by floating
if (renderer.y >= thresholdY) {
renderer.x += diffX;
renderer.settings.width += diffWidth;
return true;
} else if(el && el.nodeType === 1 && !SkipNode[el.nodeName] && renderer.x+el.width > (renderer.pdf.margins_doc.left + renderer.pdf.margins_doc.width)) {
renderer.x += diffX;
renderer.y = thresholdY;
renderer.settings.width += diffWidth;
return true;
} else {
return false;
}
}).bind(this, (imagesCSS['float'] === 'left') ? -cn.width : 0, renderer.y+cn.height, cn.width));

//reset floating by clear:both divs
//just set cursorY after the floating element
renderer.watchFunctions.push((function(yPositionAfterFloating, pages, el) {
if (renderer.y < yPositionAfterFloating && pages === renderer.pdf.internal.getNumberOfPages()) {
if (el.nodeType === 1 && GetCSS(el).clear === 'both') {
renderer.y = yPositionAfterFloating;
return true;
} else {
return false;
}
} else {
return true;
}
}).bind(this, renderer.y+cn.height, renderer.pdf.internal.getNumberOfPages()));

//if floating is set we decrease the available width by the image width
renderer.settings.width -= cn.width;
//if left just add the image width to the X coordinate
if (imagesCSS['float'] === 'left') {
renderer.x += cn.width;
}
}
//if no floating is set, move the rendering cursor after the image height
} else {
renderer.y += cn.height;
}

/*** TABLE RENDERING ***/
} else if (cn.nodeName === "TABLE") {
table2json = tableToJson(cn, renderer);
renderer.y += 10;
Expand Down Expand Up @@ -3466,6 +3536,25 @@ var jsPDF = (function(global) {
y : this.y
};
};

//Checks if we have to execute some watcher functions
//e.g. to end text floating around an image
Renderer.prototype.executeWatchFunctions = function(el) {
var ret = false;
var narray = [];
if (this.watchFunctions.length > 0) {
for(var i=0; i< this.watchFunctions.length; ++i) {
if (this.watchFunctions[i](el) === true) {
ret = true;
} else {
narray.push(this.watchFunctions[i]);
}
}
this.watchFunctions = narray;
}
return ret;
};

Renderer.prototype.splitFragmentsIntoLines = function (fragments, styles) {
var currentLineLength,
defaultFontSize,
Expand Down Expand Up @@ -3561,14 +3650,22 @@ var jsPDF = (function(global) {
};
Renderer.prototype.RenderTextFragment = function (text, style) {
var defaultFontSize,
font;
font,
maxLineHeight;

maxLineHeight = 0;
defaultFontSize = 12;

if (this.pdf.internal.pageSize.height - this.pdf.margins_doc.bottom < this.y + this.pdf.internal.getFontSize()) {
this.pdf.internal.write("ET", "Q");
this.pdf.addPage();
this.y = this.pdf.margins_doc.top;
this.pdf.internal.write("q", "BT", this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), "Td");
//move cursor by one line on new page
maxLineHeight = Math.max(maxLineHeight, style["line-height"], style["font-size"]);
this.pdf.internal.write(0, (-1 * defaultFontSize * maxLineHeight).toFixed(2), "Td");
}
defaultFontSize = 12;

font = this.pdf.internal.getFont(style["font-family"], style["font-style"]);

//set the word spacing for e.g. justify style
Expand Down Expand Up @@ -3627,6 +3724,7 @@ var jsPDF = (function(global) {

//stores the current indent of cursor position
var currentIndent = 0;

while (lines.length) {
line = lines.shift();
maxLineHeight = 0;
Expand Down Expand Up @@ -3658,6 +3756,32 @@ var jsPDF = (function(global) {
i++;
}
this.y += maxLineHeight * fontToUnitRatio;

//if some watcher function was executed sucessful, so e.g. margin and widths were changed,
//reset line drawing and calculate position and lines again
//e.g. to stop text floating around an image
if (this.executeWatchFunctions(line[0][1]) && lines.length > 0) {
var localFragments = [];
var localStyles = [];
//create fragement array of
lines.forEach(function(localLine) {
var i = 0;
var l = localLine.length;
while (i !== l) {
if (localLine[i][0]) {
localFragments.push(localLine[i][0]+' ');
localStyles.push(localLine[i][1]);
}
++i;
}
});
//split lines again due to possible coordinate changes
lines = this.splitFragmentsIntoLines(PurgeWhiteSpace(localFragments), localStyles);
//reposition the current cursor
out("ET", "Q");
out("q", "BT", this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), "Td");
}

}
if (cb && typeof cb === "function") {
cb.call(this, this.x - 9, this.y - fontSize / 2);
Expand Down Expand Up @@ -3710,6 +3834,15 @@ var jsPDF = (function(global) {
center : "center",
justify : "justify"
};
FloatMap = {
none : 'none',
right: 'right',
left: 'left'
};
ClearMap = {
none : 'none',
both : 'both'
};
UnitedNumberMap = {
normal : 1
};
Expand Down Expand Up @@ -3743,7 +3876,8 @@ var jsPDF = (function(global) {
settings = {};
if (!settings.elementHandlers)
settings.elementHandlers = {};
return process(this, HTML, x || 4, y || 4, settings, callback);

return process(this, HTML, isNaN(x) ? 4 : x, isNaN(y) ? 4 : y, settings, callback);
};
})(jsPDF.API);
/** ====================================================================
Expand Down Expand Up @@ -4361,7 +4495,7 @@ jsPDFAPI.addSVG = function(svgtext, x, y, w, h) {

var undef

if (x === undef || x === undef) {
if (x === undef || y === undef) {
throw new Error("addSVG needs values for 'x' and 'y'");
}

Expand Down Expand Up @@ -5257,7 +5391,7 @@ jsPDFAPI.putTotalPages = function(pageExpression) {
})(jsPDF.API);
/* Blob.js
* A Blob implementation.
* 2014-05-27
* 2014-05-31
*
* By Eli Grey, http://eligrey.com
* By Devin Samarin, https://github.com/eboyjr
Expand Down Expand Up @@ -5417,7 +5551,8 @@ jsPDFAPI.putTotalPages = function(pageExpression) {
return "[object Blob]";
};
FB_proto.close = function() {
this.size = this.data.length = 0;
this.size = 0;
delete this.data;
};
return FakeBlobBuilder;
}(view));
Expand Down Expand Up @@ -5669,7 +5804,7 @@ var saveAs = saveAs

if (typeof module !== "undefined" && module !== null) {
module.exports = saveAs;
} else if ((typeof define !== "undefined" && define !== null) && (define.amd != null)) {
} else if ((typeof define !== "undefined" && 0)) {
define([], function() {
return saveAs;
});
Expand Down
14 changes: 7 additions & 7 deletions dist/jspdf.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libs/Blob.js
Submodule Blob.js updated 1 files
+3 −2 Blob.js

0 comments on commit da257c2

Please sign in to comment.