Skip to content

Commit

Permalink
Fixed #257
Browse files Browse the repository at this point in the history
  • Loading branch information
diegocr committed May 13, 2014
1 parent 4952bd2 commit e931375
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "jspdf",
"version": "1.0.131",
"version": "1.0.133",
"homepage": "https://github.com/mrrio/jspdf",
"description": "PDF Document creation from JavaScript",
"main": "dist/jspdf.min.js",
Expand Down
28 changes: 17 additions & 11 deletions dist/jspdf.debug.js
@@ -1,7 +1,7 @@
/** @preserve
* jsPDF - PDF Document creation from JavaScript
* Version 1.0.131-git Built on 2014-05-11T20:51
* CommitID 9ca4a6ded0
* Version 1.0.133-git Built on 2014-05-13T00:23
* CommitID 4952bd270a
*
* Copyright (c) 2010-2014 James Hall, https://github.com/MrRio/jsPDF
* 2010 Aaron Spike, https://github.com/acspike
Expand Down Expand Up @@ -1693,7 +1693,7 @@ var jsPDF = (function(global) {
* pdfdoc.mymethod() // <- !!!!!!
*/
jsPDF.API = {events:[]};
jsPDF.version = "1.0.131-debug 2014-05-11T20:51:diegocr";
jsPDF.version = "1.0.133-debug 2014-05-13T00:23:diegocr";

if (typeof define === 'function') {
define(function() {
Expand Down Expand Up @@ -2440,7 +2440,7 @@ var jsPDF = (function(global) {
return this;
};
})(jsPDF.API);
/** ====================================================================
/** ====================================================================
* jsPDF Cell plugin
* Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com
* 2013 Eduardo Menezes de Morais, eduardo.morais@usp.br
Expand All @@ -2456,10 +2456,10 @@ var jsPDF = (function(global) {
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Expand Down Expand Up @@ -2488,7 +2488,8 @@ var jsPDF = (function(global) {
},
getLastCellPosition = function () {
return lastCellPos;
};
},
NO_MARGINS = {left:0, top:0, bottom: 0};

jsPDFAPI.setHeaderFunction = function (func) {
headerFunction = func;
Expand Down Expand Up @@ -2520,9 +2521,11 @@ var jsPDF = (function(global) {
};

jsPDFAPI.cellAddPage = function () {
var margins = this.margins || NO_MARGINS;

this.addPage();

setLastCellPosition(this.margins.left, this.margins.top, undefined, undefined);
setLastCellPosition(margins.left, margins.top, undefined, undefined);
//setLastCellPosition(undefined, undefined, undefined, undefined, undefined);
pages += 1;
};
Expand All @@ -2543,7 +2546,8 @@ var jsPDF = (function(global) {
y = curCell.y;
} else {
//New line
if ((curCell.y + curCell.h + h + margin) >= this.internal.pageSize.height - this.margins.bottom) {
var margins = this.margins || NO_MARGINS;
if ((curCell.y + curCell.h + h + margin) >= this.internal.pageSize.height - margins.bottom) {
this.cellAddPage();
if (this.printHeaders && this.tableHeaderRow) {
this.printHeaderRow(ln, true);
Expand Down Expand Up @@ -2645,7 +2649,9 @@ var jsPDF = (function(global) {
autoSize = false,
printHeaders = true,
fontSize = 12,
margins = {left:0, top:0, bottom: 0, width: this.internal.pageSize.width};
margins = NO_MARGINS;

margins.width = this.internal.pageSize.width;

if (config) {
//override config defaults if the user has specified non-default behavior:
Expand Down Expand Up @@ -2812,7 +2818,7 @@ var jsPDF = (function(global) {

tableHeaderCell = this.tableHeaderRow[i];
if (new_page) {
tableHeaderCell[1] = this.margins.top;
tableHeaderCell[1] = this.margins && this.margins.top || 0;
tempHeaderConf.push(tableHeaderCell);
}
tmpArray = [].concat(tableHeaderCell);
Expand Down
8 changes: 4 additions & 4 deletions dist/jspdf.min.js

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions jspdf.plugin.cell.js
@@ -1,4 +1,4 @@
/** ====================================================================
/** ====================================================================
* jsPDF Cell plugin
* Copyright (c) 2013 Youssef Beddad, youssef.beddad@gmail.com
* 2013 Eduardo Menezes de Morais, eduardo.morais@usp.br
Expand All @@ -14,10 +14,10 @@
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Expand Down Expand Up @@ -46,7 +46,8 @@
},
getLastCellPosition = function () {
return lastCellPos;
};
},
NO_MARGINS = {left:0, top:0, bottom: 0};

jsPDFAPI.setHeaderFunction = function (func) {
headerFunction = func;
Expand Down Expand Up @@ -78,9 +79,11 @@
};

jsPDFAPI.cellAddPage = function () {
var margins = this.margins || NO_MARGINS;

this.addPage();

setLastCellPosition(this.margins.left, this.margins.top, undefined, undefined);
setLastCellPosition(margins.left, margins.top, undefined, undefined);
//setLastCellPosition(undefined, undefined, undefined, undefined, undefined);
pages += 1;
};
Expand All @@ -101,7 +104,8 @@
y = curCell.y;
} else {
//New line
if ((curCell.y + curCell.h + h + margin) >= this.internal.pageSize.height - this.margins.bottom) {
var margins = this.margins || NO_MARGINS;
if ((curCell.y + curCell.h + h + margin) >= this.internal.pageSize.height - margins.bottom) {
this.cellAddPage();
if (this.printHeaders && this.tableHeaderRow) {
this.printHeaderRow(ln, true);
Expand Down Expand Up @@ -203,7 +207,9 @@
autoSize = false,
printHeaders = true,
fontSize = 12,
margins = {left:0, top:0, bottom: 0, width: this.internal.pageSize.width};
margins = NO_MARGINS;

margins.width = this.internal.pageSize.width;

if (config) {
//override config defaults if the user has specified non-default behavior:
Expand Down Expand Up @@ -370,7 +376,7 @@

tableHeaderCell = this.tableHeaderRow[i];
if (new_page) {
tableHeaderCell[1] = this.margins.top;
tableHeaderCell[1] = this.margins && this.margins.top || 0;
tempHeaderConf.push(tableHeaderCell);
}
tmpArray = [].concat(tableHeaderCell);
Expand Down

0 comments on commit e931375

Please sign in to comment.