@flowaccount/pdfmake 1.0.7-staging.1 → 1.0.7-staging.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/pdfmake.js +610 -483
- package/build/pdfmake.min.js +2 -2
- package/build/pdfmake.min.js.map +1 -1
- package/package.json +1 -1
- package/src/layoutBuilder.js +125 -1
- package/src/tableProcessor.js +9 -3
- package/src/textTools.js +1 -1
package/package.json
CHANGED
package/src/layoutBuilder.js
CHANGED
|
@@ -538,7 +538,8 @@ LayoutBuilder.prototype.processNode = function (node) {
|
|
|
538
538
|
startY: ctx.y,
|
|
539
539
|
startPage: ctx.page,
|
|
540
540
|
availableHeight: ctx.availableHeight,
|
|
541
|
-
itemCount: currentPage ? currentPage.items.length : 0
|
|
541
|
+
itemCount: currentPage ? currentPage.items.length : 0,
|
|
542
|
+
x: ctx.x
|
|
542
543
|
};
|
|
543
544
|
}
|
|
544
545
|
|
|
@@ -683,6 +684,129 @@ LayoutBuilder.prototype.processNode = function (node) {
|
|
|
683
684
|
// Intermediate pages (remark only) should not be repositioned
|
|
684
685
|
var pageIdx = ctx.page;
|
|
685
686
|
if (pageIdx > preRenderState.startPage) {
|
|
687
|
+
// Also reposition items on the START page (where summary might be)
|
|
688
|
+
var startPage = pages[preRenderState.startPage];
|
|
689
|
+
if (startPage && startPage.items && startPage.items.length > 0) {
|
|
690
|
+
var startPageHeight = startPage.pageSize.height;
|
|
691
|
+
var startPageBottom = startPageHeight - pageMargins.bottom;
|
|
692
|
+
|
|
693
|
+
// Find content bottom on start page
|
|
694
|
+
var startContentBottom = 0;
|
|
695
|
+
for (var si = 0; si < startPage.items.length; si++) {
|
|
696
|
+
var sItem = startPage.items[si];
|
|
697
|
+
var sItemBottom = 0;
|
|
698
|
+
if (sItem.item) {
|
|
699
|
+
if (typeof sItem.item.y === 'number') {
|
|
700
|
+
var sh = 0;
|
|
701
|
+
// Line items have getHeight() method
|
|
702
|
+
if (sItem.type === 'line' && typeof sItem.item.getHeight === 'function') {
|
|
703
|
+
sh = sItem.item.getHeight();
|
|
704
|
+
} else {
|
|
705
|
+
sh = sItem.item.h || sItem.item.height || 0;
|
|
706
|
+
}
|
|
707
|
+
sItemBottom = sItem.item.y + sh;
|
|
708
|
+
}
|
|
709
|
+
if (typeof sItem.item.y2 === 'number' && sItem.item.y2 > sItemBottom) {
|
|
710
|
+
sItemBottom = sItem.item.y2;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
if (sItemBottom > startContentBottom) {
|
|
714
|
+
startContentBottom = sItemBottom;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
// Calculate gap and move items on start page
|
|
719
|
+
var startGapHeight = startPageBottom - startContentBottom;
|
|
720
|
+
if (startGapHeight > 0) {
|
|
721
|
+
var startStackStartY = preRenderState.startY;
|
|
722
|
+
for (var si = 0; si < startPage.items.length; si++) {
|
|
723
|
+
var sItem = startPage.items[si];
|
|
724
|
+
var sItemY = null;
|
|
725
|
+
if (sItem.item && typeof sItem.item.y1 === 'number') {
|
|
726
|
+
sItemY = sItem.item.y1;
|
|
727
|
+
} else if (sItem.item && typeof sItem.item.y === 'number') {
|
|
728
|
+
sItemY = sItem.item.y;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
// Skip items fully above footer start
|
|
732
|
+
if (sItemY === null || sItemY < startStackStartY) continue;
|
|
733
|
+
|
|
734
|
+
// Move item down
|
|
735
|
+
if (sItem.item && typeof sItem.item.y === 'number') {
|
|
736
|
+
sItem.item.y += startGapHeight;
|
|
737
|
+
}
|
|
738
|
+
if (sItem.item && typeof sItem.item.y1 === 'number') {
|
|
739
|
+
sItem.item.y1 += startGapHeight;
|
|
740
|
+
}
|
|
741
|
+
if (sItem.item && typeof sItem.item.y2 === 'number') {
|
|
742
|
+
sItem.item.y2 += startGapHeight;
|
|
743
|
+
}
|
|
744
|
+
// Handle polylines (points array)
|
|
745
|
+
if (sItem.item && sItem.item.points && Array.isArray(sItem.item.points)) {
|
|
746
|
+
for (var spi = 0; spi < sItem.item.points.length; spi++) {
|
|
747
|
+
if (typeof sItem.item.points[spi].y === 'number') {
|
|
748
|
+
sItem.item.points[spi].y += startGapHeight;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// MULTI-PAGE: Draw guide lines in the gap area (same as single-page)
|
|
755
|
+
var colSpec = node._footerGapOption && node._footerGapOption.columns ? node._footerGapOption.columns : (self._footerGapOption && self._footerGapOption.columns);
|
|
756
|
+
if (colSpec) {
|
|
757
|
+
var rawWidths = colSpec.content && colSpec.content.vLines ? colSpec.content.vLines : [];
|
|
758
|
+
if (rawWidths && rawWidths.length > 1) {
|
|
759
|
+
var style = (colSpec.style || {});
|
|
760
|
+
var lw = style.lineWidth != null ? style.lineWidth : 0.5;
|
|
761
|
+
var lc = style.color || '#000000';
|
|
762
|
+
var dashCfg = style.dash;
|
|
763
|
+
var includeOuter = colSpec.includeOuter !== false;
|
|
764
|
+
var startIndex = includeOuter ? 0 : 1;
|
|
765
|
+
var endIndex = includeOuter ? rawWidths.length : rawWidths.length - 1;
|
|
766
|
+
var pageX = preRenderState.x || pageMargins.left;
|
|
767
|
+
|
|
768
|
+
for (var ci = startIndex; ci < endIndex; ci++) {
|
|
769
|
+
var xGuide = pageX + rawWidths[ci] - 0.25;
|
|
770
|
+
// Extend first and last vertical lines to content bottom after moving
|
|
771
|
+
var isFirstOrLast = (ci === 0) || (ci === rawWidths.length - 1);
|
|
772
|
+
var vLineY2 = isFirstOrLast ? (startContentBottom + startGapHeight) : (startStackStartY + startGapHeight);
|
|
773
|
+
startPage.items.push({
|
|
774
|
+
type: 'vector',
|
|
775
|
+
item: {
|
|
776
|
+
type: 'line',
|
|
777
|
+
x1: xGuide,
|
|
778
|
+
y1: startStackStartY,
|
|
779
|
+
x2: xGuide,
|
|
780
|
+
y2: vLineY2,
|
|
781
|
+
lineWidth: lw,
|
|
782
|
+
lineColor: lc,
|
|
783
|
+
dash: dashCfg ? {
|
|
784
|
+
length: dashCfg.length,
|
|
785
|
+
space: dashCfg.space != null ? dashCfg.space : dashCfg.gap
|
|
786
|
+
} : undefined,
|
|
787
|
+
_footerGuideLine: true
|
|
788
|
+
}
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
// Remove existing horizontal line at startStackStartY (drawn by tableProcessor)
|
|
793
|
+
// It's at wrong position now - we'll draw new one at bottom of gap
|
|
794
|
+
for (var ri = startPage.items.length - 1; ri >= 0; ri--) {
|
|
795
|
+
var rItem = startPage.items[ri];
|
|
796
|
+
if (rItem.type === 'vector' && rItem.item && rItem.item.type === 'line') {
|
|
797
|
+
// Check if it's a horizontal line at startStackStartY
|
|
798
|
+
if (Math.abs(rItem.item.y1 - startStackStartY) < 1 &&
|
|
799
|
+
Math.abs(rItem.item.y2 - startStackStartY) < 1) {
|
|
800
|
+
startPage.items.splice(ri, 1);
|
|
801
|
+
break;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
|
|
686
810
|
var page = pages[pageIdx];
|
|
687
811
|
if (page && page.items && page.items.length > 0) {
|
|
688
812
|
var pageHeight = page.pageSize.height;
|
package/src/tableProcessor.js
CHANGED
|
@@ -560,11 +560,13 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks, nextRo
|
|
|
560
560
|
var ctx = writer.context();
|
|
561
561
|
var currentPage = ctx.getCurrentPage && ctx.getCurrentPage();
|
|
562
562
|
var pageHeight = currentPage ? (currentPage.pageSize.height - ctx.pageMargins.bottom) : 0;
|
|
563
|
-
|
|
563
|
+
var footerGapOptBreak = ctx._footerGapOption;
|
|
564
|
+
var hLineY = (footerGapOptBreak && footerGapOptBreak.enabled) ? pageHeight - 0.25 : y2;
|
|
564
565
|
if (willBreak && this.layout.hLineWhenBroken !== false) {
|
|
565
566
|
// Check if we're at the true page bottom
|
|
566
567
|
var isAtTruePageBottom = (pageHeight - y2) <= nearBottomThreshold;
|
|
567
|
-
|
|
568
|
+
// Use pageHeight for footer gap tables, y2 for normal tables
|
|
569
|
+
this.drawHorizontalLine(rowIndex + 1, writer, hLineY, true, null, isAtTruePageBottom);
|
|
568
570
|
}
|
|
569
571
|
if (rowBreakWithoutHeader && this.layout.hLineWhenBroken !== false) {
|
|
570
572
|
// Check if previous segment ended at true page bottom
|
|
@@ -573,6 +575,10 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks, nextRo
|
|
|
573
575
|
this.drawHorizontalLine(rowIndex, writer, y1, true, null, prevWasAtPageBottom);
|
|
574
576
|
}
|
|
575
577
|
|
|
578
|
+
// vLineY: ONLY use hLineY when BOTH willBreak AND footerGapOptBreak.enabled are true
|
|
579
|
+
// Otherwise use y2 (original behavior) to avoid NaN errors
|
|
580
|
+
var vLineY = (willBreak && footerGapOptBreak && footerGapOptBreak.enabled) ? hLineY : y2;
|
|
581
|
+
|
|
576
582
|
for (i = 0, l = xs.length; i < l; i++) {
|
|
577
583
|
var leftCellBorder = false;
|
|
578
584
|
var rightCellBorder = false;
|
|
@@ -599,7 +605,7 @@ TableProcessor.prototype.endRow = function (rowIndex, writer, pageBreaks, nextRo
|
|
|
599
605
|
}
|
|
600
606
|
|
|
601
607
|
if (leftCellBorder) {
|
|
602
|
-
this.drawVerticalLine(xs[i].x, y1 - hzLineOffset,
|
|
608
|
+
this.drawVerticalLine(xs[i].x, y1 - hzLineOffset, vLineY + this.bottomLineWidth, xs[i].index, writer, rowIndex, xs[i - 1] ? xs[i - 1].index : null);
|
|
603
609
|
}
|
|
604
610
|
|
|
605
611
|
if (i < l - 1) {
|
package/src/textTools.js
CHANGED
|
@@ -317,7 +317,7 @@ function getStyleProperty(item, styleContextStack, property, defaultValue) {
|
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
if(property === 'bold' && (item.text === '' || item.text === '\u200B')) {
|
|
320
|
-
return false
|
|
320
|
+
return false;
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
if (value !== null && value !== undefined) {
|