|
621 | 621 | return $frame.document.body; |
622 | 622 | })(element.replace(/<\/?script[^>]*?>/gi, '')); |
623 | 623 | } |
624 | | - var r = new Renderer(pdf, x, y, settings); |
| 624 | + var r = new Renderer(pdf, x, y, settings), out; |
625 | 625 |
|
626 | 626 | // 1. load images |
627 | 627 | // 2. prepare optional footer elements |
|
631 | 631 | DrillForContent(element, r, settings.elementHandlers); |
632 | 632 | //send event dispose for final taks (e.g. footer totalpage replacement) |
633 | 633 | r.pdf.internal.events.publish('htmlRenderingFinished'); |
634 | | - r = r.dispose(); |
635 | | - if (typeof callback === 'function') callback(r); |
| 634 | + out = r.dispose(); |
| 635 | + if (typeof callback === 'function') callback(out); |
636 | 636 | else if (found_images) console.error('jsPDF Warning: rendering issues? provide a callback to fromHTML!'); |
637 | 637 | }); |
638 | | - return pdf; |
| 638 | + return out || {x: r.x, y:r.y}; |
639 | 639 | }; |
640 | 640 | Renderer.prototype.init = function () { |
641 | 641 | this.paragraph = { |
|
648 | 648 | this.pdf.internal.write("Q"); |
649 | 649 | return { |
650 | 650 | x : this.x, |
651 | | - y : this.y |
| 651 | + y : this.y, |
| 652 | + ready:true |
652 | 653 | }; |
653 | 654 | }; |
654 | 655 |
|
|
775 | 776 | this.pdf.internal.write("ET", "Q"); |
776 | 777 | this.pdf.addPage(); |
777 | 778 | this.y = this.pdf.margins_doc.top; |
778 | | - this.pdf.internal.write("q", "BT", this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), "Td"); |
| 779 | + this.pdf.internal.write("q", "BT 0 g", this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), "Td"); |
779 | 780 | //move cursor by one line on new page |
780 | 781 | maxLineHeight = Math.max(maxLineHeight, style["line-height"], style["font-size"]); |
781 | 782 | this.pdf.internal.write(0, (-1 * defaultFontSize * maxLineHeight).toFixed(2), "Td"); |
|
835 | 836 | i = void 0; |
836 | 837 | l = void 0; |
837 | 838 | this.y += paragraphspacing_before; |
838 | | - out("q", "BT", this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), "Td"); |
| 839 | + out("q", "BT 0 g", this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), "Td"); |
839 | 840 |
|
840 | 841 | //stores the current indent of cursor position |
841 | 842 | var currentIndent = 0; |
|
894 | 895 | lines = this.splitFragmentsIntoLines(PurgeWhiteSpace(localFragments), localStyles); |
895 | 896 | //reposition the current cursor |
896 | 897 | out("ET", "Q"); |
897 | | - out("q", "BT", this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), "Td"); |
| 898 | + out("q", "BT 0 g", this.pdf.internal.getCoordinateString(this.x), this.pdf.internal.getVerticalCoordinateString(this.y), "Td"); |
898 | 899 | } |
899 | 900 |
|
900 | 901 | } |
|
0 commit comments