From edf1c20bc8f0fa5bf9f1f2dee2bc091203eb0b9b Mon Sep 17 00:00:00 2001 From: jirikavi Date: Thu, 2 Jul 2015 10:56:14 +0200 Subject: [PATCH 1/4] enable settings of font size via css definition --- plugins/cell.js | 3 +++ plugins/from_html.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/cell.js b/plugins/cell.js index 67c3c5691..4c08fc1b3 100644 --- a/plugins/cell.js +++ b/plugins/cell.js @@ -233,6 +233,9 @@ if(config.fontSize){ fontSize = config.fontSize; } + if (config.css['font-size']) { + fontSize = config.css['font-size'] * 16; + } if(config.margins){ margins = config.margins; } diff --git a/plugins/from_html.js b/plugins/from_html.js index 8403d9d4a..c82713731 100644 --- a/plugins/from_html.js +++ b/plugins/from_html.js @@ -452,7 +452,8 @@ renderer.pdf.table(renderer.x, renderer.y, table2json.rows, table2json.headers, { autoSize : false, printHeaders : true, - margins : renderer.pdf.margins_doc + margins: renderer.pdf.margins_doc, + css: GetCSS(cn) }); renderer.y = renderer.pdf.lastCellPos.y + renderer.pdf.lastCellPos.h + 20; } else if (cn.nodeName === "OL" || cn.nodeName === "UL") { From 29f3e9b93a680664ce57c75231b2a80a1c8437b6 Mon Sep 17 00:00:00 2001 From: jirikavi Date: Thu, 2 Jul 2015 10:57:44 +0200 Subject: [PATCH 2/4] get y coordinate after html rendering to PDF --- plugins/from_html.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/from_html.js b/plugins/from_html.js index c82713731..10bfe44f7 100644 --- a/plugins/from_html.js +++ b/plugins/from_html.js @@ -503,6 +503,7 @@ } i++; } + elementHandlers.outY = renderer.y; if (isBlock) { return renderer.setBlockBoundary(cb); From 47e237bd3f8b0934b182d6633193448222c37d6d Mon Sep 17 00:00:00 2001 From: jirikavi Date: Thu, 2 Jul 2015 10:59:17 +0200 Subject: [PATCH 3/4] enable dynamic set up of printHeaders --- plugins/from_html.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/from_html.js b/plugins/from_html.js index 10bfe44f7..ec9b447eb 100644 --- a/plugins/from_html.js +++ b/plugins/from_html.js @@ -451,7 +451,7 @@ renderer.y += 10; renderer.pdf.table(renderer.x, renderer.y, table2json.rows, table2json.headers, { autoSize : false, - printHeaders : true, + printHeaders: elementHandlers.printHeaders, margins: renderer.pdf.margins_doc, css: GetCSS(cn) }); From e5844dced9394db1d4a6d64ec12eb5a251d55f01 Mon Sep 17 00:00:00 2001 From: jirikavi Date: Thu, 2 Jul 2015 11:02:08 +0200 Subject: [PATCH 4/4] fix position of elements in PDF after page break --- plugins/cell.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/cell.js b/plugins/cell.js index 4c08fc1b3..b247c655e 100644 --- a/plugins/cell.js +++ b/plugins/cell.js @@ -105,6 +105,7 @@ jsPDFAPI.cell = function (x, y, w, h, txt, ln, align) { var curCell = getLastCellPosition(); + var pgAdded = false; // If this is not the first cell, we must change its position if (curCell.ln !== undefined) { @@ -117,13 +118,14 @@ var margins = this.margins || NO_MARGINS; if ((curCell.y + curCell.h + h + margin) >= this.internal.pageSize.height - margins.bottom) { this.cellAddPage(); + pgAdded = true; if (this.printHeaders && this.tableHeaderRow) { this.printHeaderRow(ln, true); } } //We ignore the passed y: the lines may have diferent heights y = (getLastCellPosition().y + getLastCellPosition().h); - + if (pgAdded) y = margin + 10; } } @@ -393,6 +395,7 @@ tableHeaderCell = this.tableHeaderRow[i]; if (new_page) { + this.margins.top = margin; tableHeaderCell[1] = this.margins && this.margins.top || 0; tempHeaderConf.push(tableHeaderCell); }