Skip to content

Commit

Permalink
0.2.14
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Oct 9, 2024
1 parent d4b944c commit 792a942
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 34 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## Unreleased
## 0.2.14 - 2024-10-09

- Fixed drawing top horizontal line of the table with page break
- Fixed uncaught Error when rowSpan and dontBreakRows combined
Expand Down
84 changes: 56 additions & 28 deletions build/pdfmake.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! pdfmake v0.2.13, @license MIT, @link http://pdfmake.org */
/*! pdfmake v0.2.14, @license MIT, @link http://pdfmake.org */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
Expand Down Expand Up @@ -15742,7 +15742,7 @@ LayoutBuilder.prototype.processRow = function (_ref) {
var discountY = 0;
if (dontBreakRows) {
// Calculate how many points we have to discount to Y when dontBreakRows and rowSpan are combined
var ctxBeforeRowSpanLastRow = self.writer.contextStack[self.writer.contextStack.length - 1];
var ctxBeforeRowSpanLastRow = self.writer.writer.contextStack[self.writer.writer.contextStack.length - 1];
discountY = ctxBeforeRowSpanLastRow.y - column._startingRowSpanY;
}
var originalXOffset = 0;
Expand Down Expand Up @@ -16049,7 +16049,7 @@ module.exports = LayoutBuilder;

/***/ }),

/***/ 2500:
/***/ 21458:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {

"use strict";
Expand Down Expand Up @@ -48257,8 +48257,8 @@ module.exports = function getPolyfill() {
if (
descriptor
&& typeof descriptor.get === 'function'
&& typeof RegExp.prototype.dotAll === 'boolean'
&& typeof RegExp.prototype.hasIndices === 'boolean'
&& 'dotAll' in RegExp.prototype
&& 'hasIndices' in RegExp.prototype
) {
/* eslint getter-return: 0 */
var calls = '';
Expand All @@ -48273,6 +48273,9 @@ module.exports = function getPolyfill() {
calls += 'y';
}
});

descriptor.get.call(o);

if (calls === 'dy') {
return descriptor.get;
}
Expand Down Expand Up @@ -55363,7 +55366,7 @@ module.exports = URLBrowserResolver;
var isFunction = (__webpack_require__(91867).isFunction);
var isUndefined = (__webpack_require__(91867).isUndefined);
var isNull = (__webpack_require__(91867).isNull);
var FileSaver = __webpack_require__(65209);
var FileSaver = __webpack_require__(26835);
var saveAs = FileSaver.saveAs;

var defaultClientFonts = {
Expand Down Expand Up @@ -57531,10 +57534,13 @@ ElementWriter.prototype.alignCanvas = function (node) {
}
};

ElementWriter.prototype.addVector = function (vector, ignoreContextX, ignoreContextY, index) {
ElementWriter.prototype.addVector = function (vector, ignoreContextX, ignoreContextY, index, forcePage) {
var context = this.context;
var page = context.getCurrentPage(),
position = this.getCurrentPositionOnPage();
var page = context.getCurrentPage();
if (isNumber(forcePage)) {
page = context.pages[forcePage];
}
var position = this.getCurrentPositionOnPage();

if (page) {
offsetVector(vector, ignoreContextX ? 0 : context.x, ignoreContextY ? 0 : context.y);
Expand Down Expand Up @@ -58123,8 +58129,8 @@ PageElementWriter.prototype.addQr = function (qr, index) {
});
};

PageElementWriter.prototype.addVector = function (vector, ignoreContextX, ignoreContextY, index) {
return this.writer.addVector(vector, ignoreContextX, ignoreContextY, index);
PageElementWriter.prototype.addVector = function (vector, ignoreContextX, ignoreContextY, index, forcePage) {
return this.writer.addVector(vector, ignoreContextX, ignoreContextY, index, forcePage);
};

PageElementWriter.prototype.beginClip = function (width, height) {
Expand Down Expand Up @@ -58257,7 +58263,7 @@ function _interopDefault(ex) {
return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex;
}

var PdfKit = _interopDefault(__webpack_require__(2500));
var PdfKit = _interopDefault(__webpack_require__(21458));

function getEngineInstance() {
return PdfKit;
Expand Down Expand Up @@ -60133,15 +60139,19 @@ TableProcessor.prototype.beginTable = function (writer) {

this.dontBreakRows = tableNode.table.dontBreakRows || false;

if (this.rowsWithoutPageBreak) {
if (this.rowsWithoutPageBreak || this.dontBreakRows) {
writer.beginUnbreakableBlock();
// Draw the top border of the table
this.drawHorizontalLine(0, writer);
if (this.rowsWithoutPageBreak && this.dontBreakRows) {
// We just increase the value of transactionLevel
writer.beginUnbreakableBlock();
}
}

// update the border properties of all cells before drawing any lines
prepareCellBorders(this.tableNode.table.body);

this.drawHorizontalLine(0, writer);

function getTableInnerContentWidth() {
var width = 0;

Expand Down Expand Up @@ -60240,7 +60250,12 @@ TableProcessor.prototype.beginRow = function (rowIndex, writer) {

this.rowCallback = this.onRowBreak(rowIndex, writer);
writer.tracker.startTracking('pageChanged', this.rowCallback);
if (this.dontBreakRows) {
if (rowIndex == 0 && !this.dontBreakRows && !this.rowsWithoutPageBreak) {
// We store the 'y' to draw later and if necessary the top border of the table
this._tableTopBorderY = writer.context().y;
writer.context().moveDown(this.topLineWidth);
}
if (this.dontBreakRows && rowIndex > 0) {
writer.beginUnbreakableBlock();
}
this.rowTopY = writer.context().y;
Expand All @@ -60251,7 +60266,7 @@ TableProcessor.prototype.beginRow = function (rowIndex, writer) {
writer.context().moveDown(this.rowPaddingTop);
};

TableProcessor.prototype.drawHorizontalLine = function (lineIndex, writer, overrideY) {
TableProcessor.prototype.drawHorizontalLine = function (lineIndex, writer, overrideY, moveDown = true, forcePage) {
var lineWidth = this.layout.hLineWidth(lineIndex, this.tableNode);
if (lineWidth) {
var style = this.layout.hLineStyle(lineIndex, this.tableNode);
Expand Down Expand Up @@ -60350,7 +60365,7 @@ TableProcessor.prototype.drawHorizontalLine = function (lineIndex, writer, overr
lineWidth: lineWidth,
dash: dash,
lineColor: borderColor
}, false, overrideY);
}, false, isNumber(overrideY), null, forcePage);
currentLine = null;
borderColor = null;
cellAbove = null;
Expand All @@ -60360,7 +60375,9 @@ TableProcessor.prototype.drawHorizontalLine = function (lineIndex, writer, overr
}
}

writer.context().moveDown(lineWidth);
if (moveDown) {
writer.context().moveDown(lineWidth);
}
}
};

Expand Down Expand Up @@ -60476,6 +60493,15 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks) {
ys[ys.length - 1].y1 = endingY;

var skipOrphanePadding = (ys[0].y1 - ys[0].y0 === this.rowPaddingTop);
if (rowIndex === 0 && !skipOrphanePadding && !this.rowsWithoutPageBreak && !this.dontBreakRows) {
// Draw the top border of the table
var pageTableStartedAt = null;
if (pageBreaks && pageBreaks.length > 0) {
// Get the page where table started at
pageTableStartedAt = pageBreaks[0].prevPage;
}
this.drawHorizontalLine(0, writer, this._tableTopBorderY, false, pageTableStartedAt);
}
for (var yi = (skipOrphanePadding ? 1 : 0), yl = ys.length; yi < yl; yi++) {
var willBreak = yi < ys.length - 1;
var rowBreakWithoutHeader = (yi > 0 && !this.headerRows);
Expand All @@ -60495,6 +60521,14 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks) {
this.reservedAtBottom = 0;
}

// Draw horizontal lines before the vertical lines so they are not overridden
if (willBreak && this.layout.hLineWhenBroken !== false) {
this.drawHorizontalLine(rowIndex + 1, writer, y2);
}
if (rowBreakWithoutHeader && this.layout.hLineWhenBroken !== false) {
this.drawHorizontalLine(rowIndex, writer, y1);
}

for (i = 0, l = xs.length; i < l; i++) {
var leftCellBorder = false;
var rightCellBorder = false;
Expand Down Expand Up @@ -60581,13 +60615,6 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks) {
}
}
}

if (willBreak && this.layout.hLineWhenBroken !== false) {
this.drawHorizontalLine(rowIndex + 1, writer, y2);
}
if (rowBreakWithoutHeader && this.layout.hLineWhenBroken !== false) {
this.drawHorizontalLine(rowIndex, writer, y1);
}
}

writer.context().page = endingPage;
Expand Down Expand Up @@ -60626,7 +60653,8 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks) {
if (this.dontBreakRows) {
writer.tracker.auto('pageChanged',
function () {
if (!self.headerRows && self.layout.hLineWhenBroken !== false) {
if (rowIndex > 0 && !self.headerRows && self.layout.hLineWhenBroken !== false) {
// Draw the top border of the row after a page break
self.drawHorizontalLine(rowIndex, writer);
}
},
Expand Down Expand Up @@ -61271,7 +61299,7 @@ module.exports = TraversalTracker;

/***/ }),

/***/ 65209:
/***/ 26835:
/***/ (function(module, exports, __webpack_require__) {

var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(a,b){if(true)!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (b),
Expand Down
2 changes: 1 addition & 1 deletion build/pdfmake.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/pdfmake.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/pdfmake.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pdfmake",
"version": "0.2.13",
"version": "0.2.14",
"description": "Client/server side PDF printing in pure JavaScript",
"main": "src/printer.js",
"browser": "build/pdfmake.js",
Expand Down

0 comments on commit 792a942

Please sign in to comment.