@softwear/latestcollectioncore 1.0.180 → 1.0.182
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/dist/reports.js +72 -29
- package/package.json +1 -1
- package/src/reports.ts +77 -30
- package/test/reports.spec.ts +2 -2
package/dist/reports.js
CHANGED
|
@@ -382,6 +382,7 @@ function drawSimpleObject(x, y, doc, object, printBuffer, width, height, options
|
|
|
382
382
|
function addPage(originX, originY, doc, layout, rootPrintBuffer, paperSize, options, containerChain, context) {
|
|
383
383
|
context.pendingRootStartBumpTenths = 0;
|
|
384
384
|
context.applyRootStartBumpToThisCall = false;
|
|
385
|
+
context.remainingRootStartBumpTenths = 0;
|
|
385
386
|
if (context.mode === 'measurement') {
|
|
386
387
|
// Track page count in measurement mode
|
|
387
388
|
if (context.currentPageCount === undefined) {
|
|
@@ -404,9 +405,24 @@ function addPage(originX, originY, doc, layout, rootPrintBuffer, paperSize, opti
|
|
|
404
405
|
originY = containerChain[0].object.y;
|
|
405
406
|
absoluteLowerRightHandSide.x = originX / 10;
|
|
406
407
|
absoluteLowerRightHandSide.y = originY / 10;
|
|
407
|
-
containerChain.forEach((link) => {
|
|
408
|
+
containerChain.forEach((link, linkIdx) => {
|
|
409
|
+
var _a;
|
|
410
|
+
const chainChild = (_a = containerChain[linkIdx + 1]) === null || _a === void 0 ? void 0 : _a.object;
|
|
408
411
|
link.object.children.forEach((child) => {
|
|
409
|
-
if (
|
|
412
|
+
if (child.snapToBottom)
|
|
413
|
+
return;
|
|
414
|
+
// Advance past bound repeat containers on the overflow path (they are not redrawn here; the
|
|
415
|
+
// innermost link draws their leaves). Without this, nested x/y offsets are lost on page 2+.
|
|
416
|
+
if (child.type === 'container' &&
|
|
417
|
+
chainChild &&
|
|
418
|
+
child === chainChild &&
|
|
419
|
+
!containerRedrawsAfterContinuationPage(child)) {
|
|
420
|
+
const c = child;
|
|
421
|
+
originX += c.x;
|
|
422
|
+
originY += c.y;
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
if (child.type != 'container' || containerRedrawsAfterContinuationPage(child)) {
|
|
410
426
|
const childLowerRightHandSide = addObjectToPDF(originX, originY, doc, child, link.printBuffer, paperSize, layout, options, rootPrintBuffer, [], context);
|
|
411
427
|
absoluteLowerRightHandSide.x = Math.max(absoluteLowerRightHandSide.x, childLowerRightHandSide.x);
|
|
412
428
|
absoluteLowerRightHandSide.y = Math.max(absoluteLowerRightHandSide.y, childLowerRightHandSide.y);
|
|
@@ -455,33 +471,48 @@ function drawBottomDwellers(object, originX, originY, absoluteLowerRightHandSide
|
|
|
455
471
|
* Use originX,originY as origin to displace the object's own x,y coordinates
|
|
456
472
|
*/
|
|
457
473
|
addObjectToPDF = function (originX, originY, doc, object, printBuffer, paperSize, layout, options, rootPrintBuffer, containerChain, context) {
|
|
458
|
-
var _a, _b;
|
|
459
|
-
let rootBump = 0;
|
|
474
|
+
var _a, _b, _c, _d, _f;
|
|
460
475
|
if (context.applyRootStartBumpToThisCall) {
|
|
461
|
-
|
|
476
|
+
context.remainingRootStartBumpTenths = (_a = context.pendingRootStartBumpTenths) !== null && _a !== void 0 ? _a : 0;
|
|
462
477
|
context.applyRootStartBumpToThisCall = false;
|
|
463
478
|
context.pendingRootStartBumpTenths = 0;
|
|
464
479
|
}
|
|
465
|
-
const
|
|
466
|
-
const
|
|
480
|
+
const layoutXtenths = originX + object.x;
|
|
481
|
+
const layoutYtenths = originY + object.y;
|
|
482
|
+
/** printOnlyAtStart offset only for outermost recursion and only until first positioning or addPage clears it */
|
|
483
|
+
const bumpForDrawNonContainer = containerChain.length === 0 ? (_b = context.remainingRootStartBumpTenths) !== null && _b !== void 0 ? _b : 0 : 0;
|
|
484
|
+
const x = layoutXtenths / 10;
|
|
485
|
+
const y = (layoutYtenths + bumpForDrawNonContainer) / 10;
|
|
467
486
|
const width = object.width / 10;
|
|
468
487
|
const height = object.height / 10;
|
|
469
488
|
// Keep track of the lower righthandside of all objects in this container
|
|
470
489
|
// We need to return this object so whatever calls addObjectToPDF knows how big our drawing was
|
|
471
490
|
let absoluteLowerRightHandSide = { x: x + width, y: y + height };
|
|
472
|
-
if (!object.active)
|
|
491
|
+
if (!object.active) {
|
|
492
|
+
if (bumpForDrawNonContainer !== 0)
|
|
493
|
+
context.remainingRootStartBumpTenths = 0;
|
|
473
494
|
return absoluteLowerRightHandSide;
|
|
474
|
-
|
|
495
|
+
}
|
|
496
|
+
if (object.type != 'container') {
|
|
497
|
+
if (bumpForDrawNonContainer !== 0)
|
|
498
|
+
context.remainingRootStartBumpTenths = 0;
|
|
475
499
|
drawSimpleObject(x, y, doc, object, printBuffer, width, height, options, context);
|
|
500
|
+
}
|
|
476
501
|
// Recursively draw all child objects from a container object
|
|
477
502
|
if (object.type == 'container') {
|
|
478
|
-
let originX = x * 10, originY = y * 10;
|
|
479
503
|
const source = containerLoopSource(object, printBuffer);
|
|
480
504
|
if (source === undefined) {
|
|
481
|
-
(
|
|
505
|
+
(_c = options.onAlert) === null || _c === void 0 ? void 0 : _c.call(options, { header: 'containernotfound', body: object.source, type: 'warning', timeout: 10000 });
|
|
506
|
+
if (containerChain.length === 0)
|
|
507
|
+
context.remainingRootStartBumpTenths = 0;
|
|
482
508
|
return absoluteLowerRightHandSide;
|
|
483
509
|
}
|
|
484
510
|
const nrContainers = source.length;
|
|
511
|
+
let bumpOnce = containerChain.length === 0 ? (_d = context.remainingRootStartBumpTenths) !== null && _d !== void 0 ? _d : 0 : 0;
|
|
512
|
+
if (bumpOnce !== 0 && containerChain.length === 0)
|
|
513
|
+
context.remainingRootStartBumpTenths = 0;
|
|
514
|
+
let originX = layoutXtenths;
|
|
515
|
+
let originY = layoutYtenths + bumpOnce;
|
|
485
516
|
for (let containerIndex = 0; containerIndex < nrContainers; containerIndex++) {
|
|
486
517
|
const newContainerChain = containerChain.filter(function () {
|
|
487
518
|
return true;
|
|
@@ -492,8 +523,8 @@ addObjectToPDF = function (originX, originY, doc, object, printBuffer, paperSize
|
|
|
492
523
|
const useOrphanCheck = minHeightMm != null && minHeightMm > 0;
|
|
493
524
|
if (useOrphanCheck && (object.pageBreak || originY + minHeightMm > paperSize.height - paperSize.footerHeight)) {
|
|
494
525
|
// We ran out of paper
|
|
495
|
-
originX =
|
|
496
|
-
originY =
|
|
526
|
+
originX = layoutXtenths;
|
|
527
|
+
originY = layoutYtenths + (containerChain.length === 0 ? (_f = context.remainingRootStartBumpTenths) !== null && _f !== void 0 ? _f : 0 : 0);
|
|
497
528
|
const newOrigin = addPage(originX, originY, doc, layout, rootPrintBuffer, paperSize, options, newContainerChain, context);
|
|
498
529
|
originX = newOrigin.originX;
|
|
499
530
|
originY = newOrigin.originY;
|
|
@@ -685,25 +716,31 @@ function genPDF(layout, printBuffer, options = {}) {
|
|
|
685
716
|
// Draw containers in measurement mode (same order as render)
|
|
686
717
|
let measurementTopPrintedStartBottomTenths = 0;
|
|
687
718
|
layout.objects
|
|
688
|
-
.filter((object) => object.type == 'container' && object.printOnlyAtStart)
|
|
719
|
+
.filter((object) => object.type == 'container' && object.printOnlyAtStart === true)
|
|
689
720
|
.forEach((object) => {
|
|
690
721
|
const lh = addObjectToPDF(0, 0, measurementDoc, object, printBuffer, paperSize, layout, options, printBuffer, [], measurementContext);
|
|
691
722
|
measurementTopPrintedStartBottomTenths = Math.max(measurementTopPrintedStartBottomTenths, lh.y * 10);
|
|
692
723
|
});
|
|
693
724
|
layout.objects
|
|
694
725
|
.filter((object) => object.type == 'container' &&
|
|
695
|
-
|
|
696
|
-
|
|
726
|
+
object.printOnlyAtEnd !== true &&
|
|
727
|
+
object.printOnlyAtStart !== true)
|
|
697
728
|
.forEach((object) => {
|
|
698
|
-
|
|
699
|
-
|
|
729
|
+
const bumpTenths = Math.max(0, measurementTopPrintedStartBottomTenths - object.y);
|
|
730
|
+
if (bumpTenths > 0) {
|
|
731
|
+
measurementContext.applyRootStartBumpToThisCall = true;
|
|
732
|
+
measurementContext.pendingRootStartBumpTenths = bumpTenths;
|
|
733
|
+
}
|
|
700
734
|
addObjectToPDF(0, 0, measurementDoc, object, printBuffer, paperSize, layout, options, printBuffer, [], measurementContext);
|
|
701
735
|
});
|
|
702
736
|
layout.objects
|
|
703
|
-
.filter((object) => object.type == 'container' && object.printOnlyAtEnd)
|
|
737
|
+
.filter((object) => object.type == 'container' && object.printOnlyAtEnd === true)
|
|
704
738
|
.forEach((object) => {
|
|
705
|
-
|
|
706
|
-
|
|
739
|
+
const bumpTenths = Math.max(0, measurementTopPrintedStartBottomTenths - object.y);
|
|
740
|
+
if (bumpTenths > 0) {
|
|
741
|
+
measurementContext.applyRootStartBumpToThisCall = true;
|
|
742
|
+
measurementContext.pendingRootStartBumpTenths = bumpTenths;
|
|
743
|
+
}
|
|
707
744
|
addObjectToPDF(0, 0, measurementDoc, object, printBuffer, paperSize, layout, options, printBuffer, [], measurementContext);
|
|
708
745
|
});
|
|
709
746
|
// Get total page count from measurement pass
|
|
@@ -725,7 +762,7 @@ function genPDF(layout, printBuffer, options = {}) {
|
|
|
725
762
|
drawStaticPartOfPage(doc, layout, printBuffer, paperSize, options, renderContext);
|
|
726
763
|
let renderTopPrintedStartBottomTenths = 0;
|
|
727
764
|
layout.objects
|
|
728
|
-
.filter((object) => object.type == 'container' && object.printOnlyAtStart)
|
|
765
|
+
.filter((object) => object.type == 'container' && object.printOnlyAtStart === true)
|
|
729
766
|
.forEach((object) => {
|
|
730
767
|
const lh = addObjectToPDF(0, 0, doc, object, printBuffer, paperSize, layout, options, printBuffer, [], renderContext);
|
|
731
768
|
renderTopPrintedStartBottomTenths = Math.max(renderTopPrintedStartBottomTenths, lh.y * 10);
|
|
@@ -733,18 +770,24 @@ function genPDF(layout, printBuffer, options = {}) {
|
|
|
733
770
|
// Draw containers in rendering mode (body containers after printOnlyAtStart)
|
|
734
771
|
layout.objects
|
|
735
772
|
.filter((object) => object.type == 'container' &&
|
|
736
|
-
|
|
737
|
-
|
|
773
|
+
object.printOnlyAtEnd !== true &&
|
|
774
|
+
object.printOnlyAtStart !== true)
|
|
738
775
|
.forEach((object) => {
|
|
739
|
-
|
|
740
|
-
|
|
776
|
+
const bumpTenths = Math.max(0, renderTopPrintedStartBottomTenths - object.y);
|
|
777
|
+
if (bumpTenths > 0) {
|
|
778
|
+
renderContext.applyRootStartBumpToThisCall = true;
|
|
779
|
+
renderContext.pendingRootStartBumpTenths = bumpTenths;
|
|
780
|
+
}
|
|
741
781
|
addObjectToPDF(0, 0, doc, object, printBuffer, paperSize, layout, options, printBuffer, [], renderContext);
|
|
742
782
|
});
|
|
743
783
|
// Draw printOnlyAtEnd containers once at the end (at their layout coordinates on current page)
|
|
744
|
-
const printOnlyAtEndContainers = layout.objects.filter((object) => object.type == 'container' && object.printOnlyAtEnd);
|
|
784
|
+
const printOnlyAtEndContainers = layout.objects.filter((object) => object.type == 'container' && object.printOnlyAtEnd === true);
|
|
745
785
|
printOnlyAtEndContainers.forEach((object) => {
|
|
746
|
-
|
|
747
|
-
|
|
786
|
+
const bumpTenths = Math.max(0, renderTopPrintedStartBottomTenths - object.y);
|
|
787
|
+
if (bumpTenths > 0) {
|
|
788
|
+
renderContext.applyRootStartBumpToThisCall = true;
|
|
789
|
+
renderContext.pendingRootStartBumpTenths = bumpTenths;
|
|
790
|
+
}
|
|
748
791
|
addObjectToPDF(0, 0, doc, object, printBuffer, paperSize, layout, options, printBuffer, [], renderContext);
|
|
749
792
|
});
|
|
750
793
|
return doc;
|
package/package.json
CHANGED
package/src/reports.ts
CHANGED
|
@@ -46,10 +46,14 @@ interface RenderContext {
|
|
|
46
46
|
imageAssets?: Map<string, PdfImageAsset>
|
|
47
47
|
/** Layout default font used when object.fontFamily is undefined */
|
|
48
48
|
defaultFontFamily?: string
|
|
49
|
-
/** Set with {@link pendingRootStartBumpTenths} only for top-level genPDF container draws;
|
|
49
|
+
/** Set with {@link pendingRootStartBumpTenths} only for top-level genPDF container draws; moved to remaining on entry. */
|
|
50
50
|
applyRootStartBumpToThisCall?: boolean
|
|
51
51
|
/** Vertical pad (tenths-mm) so body roots sit below rendered printOnlyAtStart siblings; use with applyRootStartBumpToThisCall only. */
|
|
52
52
|
pendingRootStartBumpTenths?: number
|
|
53
|
+
/**
|
|
54
|
+
* First-fragment bump for top-level draws from genPDF — applied with layout coords, then cleared after first positioning or addPage().
|
|
55
|
+
*/
|
|
56
|
+
remainingRootStartBumpTenths?: number
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
// We have to declare some functions that will be called by other functions but also have to call those other functions
|
|
@@ -451,6 +455,7 @@ function addPage(
|
|
|
451
455
|
): { originX: number; originY: number; x: number; y: number } {
|
|
452
456
|
context.pendingRootStartBumpTenths = 0
|
|
453
457
|
context.applyRootStartBumpToThisCall = false
|
|
458
|
+
context.remainingRootStartBumpTenths = 0
|
|
454
459
|
if (context.mode === 'measurement') {
|
|
455
460
|
// Track page count in measurement mode
|
|
456
461
|
if (context.currentPageCount === undefined) {
|
|
@@ -472,9 +477,24 @@ function addPage(
|
|
|
472
477
|
originY = containerChain[0].object.y
|
|
473
478
|
absoluteLowerRightHandSide.x = originX / 10
|
|
474
479
|
absoluteLowerRightHandSide.y = originY / 10
|
|
475
|
-
containerChain.forEach((link) => {
|
|
480
|
+
containerChain.forEach((link, linkIdx) => {
|
|
481
|
+
const chainChild = containerChain[linkIdx + 1]?.object
|
|
476
482
|
link.object.children.forEach((child) => {
|
|
477
|
-
if (
|
|
483
|
+
if (child.snapToBottom) return
|
|
484
|
+
// Advance past bound repeat containers on the overflow path (they are not redrawn here; the
|
|
485
|
+
// innermost link draws their leaves). Without this, nested x/y offsets are lost on page 2+.
|
|
486
|
+
if (
|
|
487
|
+
child.type === 'container' &&
|
|
488
|
+
chainChild &&
|
|
489
|
+
child === chainChild &&
|
|
490
|
+
!containerRedrawsAfterContinuationPage(child)
|
|
491
|
+
) {
|
|
492
|
+
const c = child as ContainerLayoutObject
|
|
493
|
+
originX += c.x
|
|
494
|
+
originY += c.y
|
|
495
|
+
return
|
|
496
|
+
}
|
|
497
|
+
if (child.type != 'container' || containerRedrawsAfterContinuationPage(child)) {
|
|
478
498
|
const childLowerRightHandSide = addObjectToPDF(originX, originY, doc, child, link.printBuffer, paperSize, layout, options, rootPrintBuffer, [], context)
|
|
479
499
|
absoluteLowerRightHandSide.x = Math.max(absoluteLowerRightHandSide.x, childLowerRightHandSide.x)
|
|
480
500
|
absoluteLowerRightHandSide.y = Math.max(absoluteLowerRightHandSide.y, childLowerRightHandSide.y)
|
|
@@ -547,34 +567,49 @@ addObjectToPDF = function (
|
|
|
547
567
|
containerChain: { object: ContainerLayoutObject; printBuffer: any }[],
|
|
548
568
|
context: RenderContext
|
|
549
569
|
): { x: number; y: number } {
|
|
550
|
-
let rootBump = 0
|
|
551
570
|
if (context.applyRootStartBumpToThisCall) {
|
|
552
|
-
|
|
571
|
+
context.remainingRootStartBumpTenths = context.pendingRootStartBumpTenths ?? 0
|
|
553
572
|
context.applyRootStartBumpToThisCall = false
|
|
554
573
|
context.pendingRootStartBumpTenths = 0
|
|
555
574
|
}
|
|
556
|
-
const
|
|
557
|
-
const
|
|
575
|
+
const layoutXtenths = originX + object.x
|
|
576
|
+
const layoutYtenths = originY + object.y
|
|
577
|
+
/** printOnlyAtStart offset only for outermost recursion and only until first positioning or addPage clears it */
|
|
578
|
+
const bumpForDrawNonContainer =
|
|
579
|
+
containerChain.length === 0 ? context.remainingRootStartBumpTenths ?? 0 : 0
|
|
580
|
+
|
|
581
|
+
const x = layoutXtenths / 10
|
|
582
|
+
const y = (layoutYtenths + bumpForDrawNonContainer) / 10
|
|
558
583
|
const width = object.width / 10
|
|
559
584
|
const height = object.height / 10
|
|
560
585
|
// Keep track of the lower righthandside of all objects in this container
|
|
561
586
|
// We need to return this object so whatever calls addObjectToPDF knows how big our drawing was
|
|
562
587
|
let absoluteLowerRightHandSide = { x: x + width, y: y + height }
|
|
563
588
|
|
|
564
|
-
if (!object.active)
|
|
565
|
-
|
|
589
|
+
if (!object.active) {
|
|
590
|
+
if (bumpForDrawNonContainer !== 0) context.remainingRootStartBumpTenths = 0
|
|
591
|
+
return absoluteLowerRightHandSide
|
|
592
|
+
}
|
|
593
|
+
if (object.type != 'container') {
|
|
594
|
+
if (bumpForDrawNonContainer !== 0) context.remainingRootStartBumpTenths = 0
|
|
595
|
+
drawSimpleObject(x, y, doc, object, printBuffer, width, height, options, context)
|
|
596
|
+
}
|
|
566
597
|
|
|
567
598
|
// Recursively draw all child objects from a container object
|
|
568
599
|
if (object.type == 'container') {
|
|
569
|
-
let originX = x * 10,
|
|
570
|
-
originY = y * 10
|
|
571
|
-
|
|
572
600
|
const source = containerLoopSource(object as ContainerLayoutObject, printBuffer)
|
|
573
601
|
if (source === undefined) {
|
|
574
602
|
options.onAlert?.({ header: 'containernotfound', body: object.source, type: 'warning', timeout: 10000 })
|
|
603
|
+
if (containerChain.length === 0) context.remainingRootStartBumpTenths = 0
|
|
575
604
|
return absoluteLowerRightHandSide
|
|
576
605
|
}
|
|
577
606
|
const nrContainers = source.length
|
|
607
|
+
|
|
608
|
+
let bumpOnce = containerChain.length === 0 ? context.remainingRootStartBumpTenths ?? 0 : 0
|
|
609
|
+
if (bumpOnce !== 0 && containerChain.length === 0) context.remainingRootStartBumpTenths = 0
|
|
610
|
+
let originX = layoutXtenths
|
|
611
|
+
let originY = layoutYtenths + bumpOnce
|
|
612
|
+
|
|
578
613
|
for (let containerIndex = 0; containerIndex < nrContainers; containerIndex++) {
|
|
579
614
|
const newContainerChain = containerChain.filter(function () {
|
|
580
615
|
return true
|
|
@@ -585,8 +620,8 @@ addObjectToPDF = function (
|
|
|
585
620
|
const useOrphanCheck = minHeightMm != null && minHeightMm > 0
|
|
586
621
|
if (useOrphanCheck && (object.pageBreak || originY + minHeightMm > paperSize.height - paperSize.footerHeight)) {
|
|
587
622
|
// We ran out of paper
|
|
588
|
-
originX =
|
|
589
|
-
originY =
|
|
623
|
+
originX = layoutXtenths
|
|
624
|
+
originY = layoutYtenths + (containerChain.length === 0 ? context.remainingRootStartBumpTenths ?? 0 : 0)
|
|
590
625
|
const newOrigin = addPage(originX, originY, doc, layout, rootPrintBuffer, paperSize, options, newContainerChain, context)
|
|
591
626
|
originX = newOrigin.originX
|
|
592
627
|
originY = newOrigin.originY
|
|
@@ -812,7 +847,7 @@ export async function genPDF(layout: Layout, printBuffer: any, options: GenPdfOp
|
|
|
812
847
|
// Draw containers in measurement mode (same order as render)
|
|
813
848
|
let measurementTopPrintedStartBottomTenths = 0
|
|
814
849
|
layout.objects
|
|
815
|
-
.filter((object) => object.type == 'container' && (object as ContainerLayoutObject).printOnlyAtStart)
|
|
850
|
+
.filter((object) => object.type == 'container' && (object as ContainerLayoutObject).printOnlyAtStart === true)
|
|
816
851
|
.forEach((object) => {
|
|
817
852
|
const lh = addObjectToPDF(0, 0, measurementDoc, object, printBuffer, paperSize, layout, options, printBuffer, [], measurementContext)
|
|
818
853
|
measurementTopPrintedStartBottomTenths = Math.max(measurementTopPrintedStartBottomTenths, lh.y * 10)
|
|
@@ -821,19 +856,25 @@ export async function genPDF(layout: Layout, printBuffer: any, options: GenPdfOp
|
|
|
821
856
|
.filter(
|
|
822
857
|
(object) =>
|
|
823
858
|
object.type == 'container' &&
|
|
824
|
-
|
|
825
|
-
|
|
859
|
+
(object as ContainerLayoutObject).printOnlyAtEnd !== true &&
|
|
860
|
+
(object as ContainerLayoutObject).printOnlyAtStart !== true
|
|
826
861
|
)
|
|
827
862
|
.forEach((object) => {
|
|
828
|
-
|
|
829
|
-
|
|
863
|
+
const bumpTenths = Math.max(0, measurementTopPrintedStartBottomTenths - object.y)
|
|
864
|
+
if (bumpTenths > 0) {
|
|
865
|
+
measurementContext.applyRootStartBumpToThisCall = true
|
|
866
|
+
measurementContext.pendingRootStartBumpTenths = bumpTenths
|
|
867
|
+
}
|
|
830
868
|
addObjectToPDF(0, 0, measurementDoc, object, printBuffer, paperSize, layout, options, printBuffer, [], measurementContext)
|
|
831
869
|
})
|
|
832
870
|
layout.objects
|
|
833
|
-
.filter((object) => object.type == 'container' && (object as ContainerLayoutObject).printOnlyAtEnd)
|
|
871
|
+
.filter((object) => object.type == 'container' && (object as ContainerLayoutObject).printOnlyAtEnd === true)
|
|
834
872
|
.forEach((object) => {
|
|
835
|
-
|
|
836
|
-
|
|
873
|
+
const bumpTenths = Math.max(0, measurementTopPrintedStartBottomTenths - object.y)
|
|
874
|
+
if (bumpTenths > 0) {
|
|
875
|
+
measurementContext.applyRootStartBumpToThisCall = true
|
|
876
|
+
measurementContext.pendingRootStartBumpTenths = bumpTenths
|
|
877
|
+
}
|
|
837
878
|
addObjectToPDF(0, 0, measurementDoc, object, printBuffer, paperSize, layout, options, printBuffer, [], measurementContext)
|
|
838
879
|
})
|
|
839
880
|
|
|
@@ -858,7 +899,7 @@ export async function genPDF(layout: Layout, printBuffer: any, options: GenPdfOp
|
|
|
858
899
|
|
|
859
900
|
let renderTopPrintedStartBottomTenths = 0
|
|
860
901
|
layout.objects
|
|
861
|
-
.filter((object) => object.type == 'container' && (object as ContainerLayoutObject).printOnlyAtStart)
|
|
902
|
+
.filter((object) => object.type == 'container' && (object as ContainerLayoutObject).printOnlyAtStart === true)
|
|
862
903
|
.forEach((object) => {
|
|
863
904
|
const lh = addObjectToPDF(0, 0, doc, object, printBuffer, paperSize, layout, options, printBuffer, [], renderContext)
|
|
864
905
|
renderTopPrintedStartBottomTenths = Math.max(renderTopPrintedStartBottomTenths, lh.y * 10)
|
|
@@ -869,22 +910,28 @@ export async function genPDF(layout: Layout, printBuffer: any, options: GenPdfOp
|
|
|
869
910
|
.filter(
|
|
870
911
|
(object) =>
|
|
871
912
|
object.type == 'container' &&
|
|
872
|
-
|
|
873
|
-
|
|
913
|
+
(object as ContainerLayoutObject).printOnlyAtEnd !== true &&
|
|
914
|
+
(object as ContainerLayoutObject).printOnlyAtStart !== true
|
|
874
915
|
)
|
|
875
916
|
.forEach((object) => {
|
|
876
|
-
|
|
877
|
-
|
|
917
|
+
const bumpTenths = Math.max(0, renderTopPrintedStartBottomTenths - object.y)
|
|
918
|
+
if (bumpTenths > 0) {
|
|
919
|
+
renderContext.applyRootStartBumpToThisCall = true
|
|
920
|
+
renderContext.pendingRootStartBumpTenths = bumpTenths
|
|
921
|
+
}
|
|
878
922
|
addObjectToPDF(0, 0, doc, object, printBuffer, paperSize, layout, options, printBuffer, [], renderContext)
|
|
879
923
|
})
|
|
880
924
|
|
|
881
925
|
// Draw printOnlyAtEnd containers once at the end (at their layout coordinates on current page)
|
|
882
926
|
const printOnlyAtEndContainers = layout.objects.filter(
|
|
883
|
-
(object) => object.type == 'container' && (object as ContainerLayoutObject).printOnlyAtEnd
|
|
927
|
+
(object) => object.type == 'container' && (object as ContainerLayoutObject).printOnlyAtEnd === true
|
|
884
928
|
)
|
|
885
929
|
printOnlyAtEndContainers.forEach((object) => {
|
|
886
|
-
|
|
887
|
-
|
|
930
|
+
const bumpTenths = Math.max(0, renderTopPrintedStartBottomTenths - object.y)
|
|
931
|
+
if (bumpTenths > 0) {
|
|
932
|
+
renderContext.applyRootStartBumpToThisCall = true
|
|
933
|
+
renderContext.pendingRootStartBumpTenths = bumpTenths
|
|
934
|
+
}
|
|
888
935
|
addObjectToPDF(0, 0, doc, object, printBuffer, paperSize, layout, options, printBuffer, [], renderContext)
|
|
889
936
|
})
|
|
890
937
|
return doc
|