Skip to content

Commit 9c70e27

Browse files
committed
empty line between first lines on new page removed
1 parent 4e6bcb4 commit 9c70e27

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

jspdf.plugin.from_html.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -756,14 +756,22 @@
756756
};
757757
Renderer.prototype.RenderTextFragment = function (text, style) {
758758
var defaultFontSize,
759-
font;
759+
font,
760+
maxLineHeight;
761+
762+
maxLineHeight = 0;
763+
defaultFontSize = 12;
764+
760765
if (this.pdf.internal.pageSize.height - this.pdf.margins_doc.bottom < this.y + this.pdf.internal.getFontSize()) {
761766
this.pdf.internal.write("ET", "Q");
762767
this.pdf.addPage();
763768
this.y = this.pdf.margins_doc.top;
764769
this.pdf.internal.write("q", "BT", this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), "Td");
770+
//move cursor by one line on new page
771+
maxLineHeight = Math.max(maxLineHeight, style["line-height"], style["font-size"]);
772+
this.pdf.internal.write(0, (-1 * defaultFontSize * maxLineHeight).toFixed(2), "Td");
765773
}
766-
defaultFontSize = 12;
774+
767775
font = this.pdf.internal.getFont(style["font-family"], style["font-style"]);
768776

769777
//set the word spacing for e.g. justify style
@@ -876,9 +884,9 @@
876884
//split lines again due to possible coordinate changes
877885
lines = this.splitFragmentsIntoLines(PurgeWhiteSpace(localFragments), localStyles);
878886
//reposition the current cursor
879-
out("ET", "Q");
887+
out("ET", "Q");
880888
out("q", "BT", this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), "Td");
881-
}
889+
}
882890

883891
}
884892
if (cb && typeof cb === "function") {

0 commit comments

Comments
 (0)