Skip to content

Commit

Permalink
empty line between first lines on new page removed
Browse files Browse the repository at this point in the history
  • Loading branch information
woolfg committed Jun 26, 2014
1 parent 4e6bcb4 commit 9c70e27
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions jspdf.plugin.from_html.js
Expand Up @@ -756,14 +756,22 @@
};
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 @@ -876,9 +884,9 @@
//split lines again due to possible coordinate changes
lines = this.splitFragmentsIntoLines(PurgeWhiteSpace(localFragments), localStyles);
//reposition the current cursor
out("ET", "Q");
out("ET", "Q");
out("q", "BT", this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), "Td");
}
}

}
if (cb && typeof cb === "function") {
Expand Down

0 comments on commit 9c70e27

Please sign in to comment.