@syncfusion/ej2-pdf-export 19.2.56 → 19.3.53

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.
@@ -28579,6 +28579,9 @@ class PdfGridLayouter extends ElementLayouter {
28579
28579
  * @private
28580
28580
  */
28581
28581
  this.breakRow = true;
28582
+ this.slr = null;
28583
+ this.remainderText = null;
28584
+ this.isPaginate = false;
28582
28585
  /**
28583
28586
  * Checks whether the x co-ordinate is need to set as client size or not.
28584
28587
  * @hidden
@@ -29001,6 +29004,10 @@ class PdfGridLayouter extends ElementLayouter {
29001
29004
  this.currentBounds.x += this.startLocation.x;
29002
29005
  this.currentBounds.y += this.startLocation.y;
29003
29006
  }
29007
+ if (this.isPaginate) {
29008
+ this.startLocation.y = this.currentBounds.y;
29009
+ this.isPaginate = false;
29010
+ }
29004
29011
  if (this.Grid.isChildGrid && row.grid.ParentCell != null) {
29005
29012
  if (this.Grid.ParentCell.row.grid.style.cellPadding != null) {
29006
29013
  if (row.rowBreakHeight + this.Grid.ParentCell.row.grid.style.cellPadding.top < this.currentBounds.height) {
@@ -29167,7 +29174,13 @@ class PdfGridLayouter extends ElementLayouter {
29167
29174
  param.bounds.height > 0 && !this.Grid.isChildGrid) {
29168
29175
  this.currentBounds.height = param.bounds.height;
29169
29176
  }
29170
- if ((param.format !== null) && !param.format.usePaginateBounds && param.bounds !== null &&
29177
+ if (typeof param.format !== 'undefined' && param.format != null && typeof param.format.usePaginateBounds !== 'undefined' && !param.format.usePaginateBounds && !(param.format.paginateBounds.x === 0 && param.format.paginateBounds.y === 0 && param.format.paginateBounds.width === 0 && param.format.paginateBounds.height === 0) && param.format.paginateBounds.y === 0) {
29178
+ this.currentBounds.y = PdfBorders.default.top.width / 2;
29179
+ }
29180
+ else {
29181
+ this.currentBounds.y = format == null ? 0 : format.paginateBounds.y;
29182
+ }
29183
+ if (typeof param.format !== 'undefined' && (param.format !== null) && typeof param.format.usePaginateBounds !== 'undefined' && !param.format.usePaginateBounds && param.bounds !== null &&
29171
29184
  param.bounds.y > 0 && !this.Grid.isChildGrid) {
29172
29185
  this.currentBounds.y = param.bounds.y;
29173
29186
  }
@@ -29612,10 +29625,28 @@ class PdfGridLayouter extends ElementLayouter {
29612
29625
  this.currentBounds.y + calculatedHeight > (this.currentBounds.height + this.startLocation.y) ||
29613
29626
  this.currentBounds.y + rowHeightWithSpan > this.currentPageBounds.height) {
29614
29627
  // If a row is repeated and still cannot fit in page, proceed draw.
29615
- if (this.Grid.LayoutFormat.break === PdfLayoutBreakType.FitPage) {
29616
- PdfGridLayouter.repeatRowIndex = this.Grid.rows.rowCollection.indexOf(row);
29628
+ let isFit = false;
29629
+ if ((this.Grid.allowRowBreakAcrossPages && !this.Grid.repeatHeader && !row.isRowHeightSet && !row.rowMergeComplete)) {
29630
+ if (this.Grid.LayoutFormat !== null && this.Grid.LayoutFormat.paginateBounds.height > 0 && typeof this.Grid.ParentCell !== 'undefined' && this.Grid.ParentCell !== null && (this.currentBounds.y + this.Grid.ParentCell.row.grid.style.cellPadding.bottom + calculatedHeight) > this.currentBounds.height) {
29631
+ isFit = this.isFitToCell((this.currentBounds.height + this.startLocation.y) - this.currentBounds.y, this.Grid, row);
29632
+ }
29633
+ else
29634
+ isFit = this.isFitToCell(this.currentPageBounds.height - this.currentBounds.y, this.Grid, row);
29635
+ if (isFit) {
29636
+ this.isPaginate = true;
29637
+ }
29617
29638
  }
29618
- if (PdfGridLayouter.repeatRowIndex > -1 && PdfGridLayouter.repeatRowIndex === row.rowIndex) {
29639
+ else if (this.Grid.allowRowBreakAcrossPages && this.Grid.LayoutFormat != null && this.Grid.LayoutFormat.layout == PdfLayoutType.Paginate && this.Grid.LayoutFormat.break != PdfLayoutBreakType.FitElement && row.isRowHeightSet && this.currentBounds.y + height > this.currentPageBounds.height) {
29640
+ isFit = this.isFitToCell(this.currentPageBounds.height - this.currentBounds.y, this.Grid, row);
29641
+ if (!isFit)
29642
+ isFit = !(this.slr !== null && this.slr.actualSize.height == 0 && this.slr.remainder != null && this.slr.remainder.length > 0 && this.remainderText == this.slr.remainder);
29643
+ if (isFit && this.slr != null && this.slr.lineCount > 1) {
29644
+ //It may text cutoff issue
29645
+ isFit = false;
29646
+ }
29647
+ this.remainderText = null;
29648
+ }
29649
+ if (PdfGridLayouter.repeatRowIndex > -1 && PdfGridLayouter.repeatRowIndex === row.rowIndex || isFit) {
29619
29650
  if (this.Grid.allowRowBreakAcrossPages) {
29620
29651
  result.isFinish = true;
29621
29652
  this.drawRowWithBreak(result, row, calculatedHeight);
@@ -29625,10 +29656,10 @@ class PdfGridLayouter extends ElementLayouter {
29625
29656
  result.isFinish = false;
29626
29657
  }
29627
29658
  }
29628
- // else {
29629
- // result.isFinish = false;
29630
- // this.drawRow(row, result, calculatedHeight);
29631
- // }
29659
+ else {
29660
+ result.isFinish = false;
29661
+ this.drawRow(row, result, calculatedHeight);
29662
+ }
29632
29663
  }
29633
29664
  else {
29634
29665
  result.isFinish = false;
@@ -29724,6 +29755,44 @@ class PdfGridLayouter extends ElementLayouter {
29724
29755
  result.bounds = new RectangleF(new PointF(result.bounds.x, result.bounds.y), new SizeF(location.x, location.y));
29725
29756
  }
29726
29757
  }
29758
+ isFitToCell(currentHeight, grid, gridRow) {
29759
+ let isFit = false;
29760
+ let layouter = new PdfStringLayouter();
29761
+ for (let i = 0; i < gridRow.cells.count; i++) {
29762
+ let cell = gridRow.cells.getCell(i);
29763
+ if (typeof cell.value !== 'undefined' && cell.value !== null && typeof cell.value === 'string') {
29764
+ let font = null;
29765
+ if (typeof cell.style.font !== 'undefined' && cell.style.font != null) {
29766
+ font = cell.style.font;
29767
+ }
29768
+ else if (typeof cell.row.style.font !== 'undefined' && cell.row.style.font != null) {
29769
+ font = cell.row.style.font;
29770
+ }
29771
+ else if (typeof cell.row.grid.style.font !== 'undefined' && cell.row.grid.style.font != null) {
29772
+ font = cell.row.grid.style.font;
29773
+ }
29774
+ else {
29775
+ font = PdfDocument.defaultFont;
29776
+ }
29777
+ this.remainderText = gridRow.cells.getCell(i).value;
29778
+ let width = gridRow.cells.getCell(i).width;
29779
+ if (grid.columns.getColumn(i).isCustomWidth && gridRow.cells.getCell(i).width > grid.columns.getColumn(i).width) {
29780
+ width = grid.columns.getColumn(i).width;
29781
+ }
29782
+ this.slr = layouter.layout(gridRow.cells.getCell(i).value, font, gridRow.cells.getCell(i).stringFormat, new SizeF(width, currentHeight), false, this.currentPageBounds);
29783
+ let height = this.slr.actualSize.height;
29784
+ if (height == 0) {
29785
+ isFit = false;
29786
+ break;
29787
+ }
29788
+ else if (currentHeight > height || (typeof this.slr.remainder !== 'undefined' && this.slr.remainder !== null)) {
29789
+ isFit = true;
29790
+ break;
29791
+ }
29792
+ }
29793
+ }
29794
+ return isFit;
29795
+ }
29727
29796
  drawRowWithBreak(result, row, calculateHeight) {
29728
29797
  let location = new PointF(this.currentBounds.x, this.currentBounds.y);
29729
29798
  if (row.grid.isChildGrid && row.grid.allowRowBreakAcrossPages && this.startLocation.x !== this.currentBounds.x) {
@@ -29777,7 +29846,7 @@ class PdfGridLayouter extends ElementLayouter {
29777
29846
  }
29778
29847
  //If still row is to be drawn, set cell finished drawing cell as false and update the text to be drawn.
29779
29848
  if (row.rowBreakHeight > 0.0) {
29780
- if (stringResult != null) {
29849
+ if (stringResult != null && typeof stringResult.remainder !== 'undefined') {
29781
29850
  row.cells.getCell(i).FinishedDrawingCell = false;
29782
29851
  row.cells.getCell(i).remainingString = stringResult.remainder == null ? ' ' : stringResult.remainder;
29783
29852
  if (row.grid.isChildGrid) {