@syncfusion/ej2-pdf-export 23.2.6 → 24.1.47

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.
@@ -16808,7 +16808,6 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
16808
16808
  this.getResources.getResources().requireProcedureSet(this.procedureSets.text);
16809
16809
  }
16810
16810
  };
16811
- /* tslint:disable */
16812
16811
  /**
16813
16812
  * @public
16814
16813
  */
@@ -16846,7 +16845,7 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
16846
16845
  this.pdfStringLayoutResult = result;
16847
16846
  this.isUseFontSize = false;
16848
16847
  }
16849
- }; /* tslint:enable */
16848
+ };
16850
16849
  PdfGraphics.prototype.drawLine = function (arg1, arg2, arg3, arg4, arg5) {
16851
16850
  if (arg2 instanceof PointF) {
16852
16851
  var temparg2 = arg2;
@@ -16866,7 +16865,6 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
16866
16865
  this.getResources.getResources().requireProcedureSet(this.procedureSets.pdf);
16867
16866
  }
16868
16867
  };
16869
- /* tslint:disable */
16870
16868
  PdfGraphics.prototype.drawRectangle = function (arg1, arg2, arg3, arg4, arg5, arg6) {
16871
16869
  if (arg1 instanceof PdfPen && typeof arg2 === 'number') {
16872
16870
  var temparg3 = arg3;
@@ -16907,6 +16905,152 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
16907
16905
  this.drawPathHelper(temparg1, temparg2, false);
16908
16906
  }
16909
16907
  };
16908
+ /**
16909
+ * Draw rounded rectangle specified by a brush, pen, coordinate pair, a width, a height and a radius.
16910
+ * ```typescript
16911
+ * // Create a new PDF document.
16912
+ * let document : PdfDocument = new PdfDocument();
16913
+ * // Create a new page
16914
+ * let page : PdfPage = document.pages.add();
16915
+ * // Create brush for draw rectangle
16916
+ * let brush : PdfSolidBrush = new PdfSolidBrush(new PdfColor(238, 130, 238));
16917
+ * // Create a new PDF pen
16918
+ * let pen: PdfPen = new PdfPen(new PdfColor(255, 0, 0), 1);
16919
+ * // Draw rounded rectangle
16920
+ * page.graphics.drawRoundedRectangle(pen, brush, 20, 20, 100, 50, 5);
16921
+ * // save the document
16922
+ * document.save('output.pdf');
16923
+ * // destroy the document
16924
+ * document.destroy();
16925
+ * ```
16926
+ * @param pen Stoke color of the rectangle.
16927
+ * @param brush Fill color of the rectangle.
16928
+ * @param x The x-coordinate of the upper-left corner of the rectangle to draw.
16929
+ * @param y The y-coordinate of the upper-left corner of the rectangle to draw.
16930
+ * @param width Width of the rectangle to draw.
16931
+ * @param height Height of the rectangle to draw.
16932
+ * @param radius Radius of the arcs to draw.
16933
+ */
16934
+ PdfGraphics.prototype.drawRoundedRectangle = function (pen, brush, x, y, width, height, radius) {
16935
+ if (pen === null) {
16936
+ throw new Error('pen');
16937
+ }
16938
+ if (brush === null) {
16939
+ throw new Error('brush');
16940
+ }
16941
+ if (radius === 0) {
16942
+ this.drawRectangle(pen, brush, x, y, width, height);
16943
+ }
16944
+ else {
16945
+ var bounds = [x, y, width, height];
16946
+ var diameter = radius * 2;
16947
+ var size = [diameter, diameter];
16948
+ var arc = [bounds[0], bounds[1], size[0], size[1]];
16949
+ this._pathPoints = [];
16950
+ this._pathTypes = [];
16951
+ var startFigure = true;
16952
+ startFigure = this._addArc(arc[0], arc[1], arc[2], arc[3], 180, 90, startFigure);
16953
+ arc[0] = (bounds[0] + bounds[2]) - diameter;
16954
+ startFigure = this._addArc(arc[0], arc[1], arc[2], arc[3], 270, 90, startFigure);
16955
+ arc[1] = (bounds[1] + bounds[3]) - diameter;
16956
+ startFigure = this._addArc(arc[0], arc[1], arc[2], arc[3], 0, 90, startFigure);
16957
+ arc[0] = bounds[0];
16958
+ startFigure = this._addArc(arc[0], arc[1], arc[2], arc[3], 90, 90, startFigure);
16959
+ var index = this._pathPoints.length - 1;
16960
+ var type = ((this._pathTypes[index]));
16961
+ type = (type | PathPointType.CloseSubpath);
16962
+ this._pathTypes[index] = (type);
16963
+ this._drawPath(pen, brush, this._pathPoints, this._pathTypes, PdfFillMode.Alternate);
16964
+ this._pathPoints = [];
16965
+ this._pathTypes = [];
16966
+ }
16967
+ };
16968
+ PdfGraphics.prototype._addArc = function (x, y, width, height, startAngle, sweepAngle, startFigure) {
16969
+ var points = this._getBezierArcPoints(x, y, (x + width), (y + height), startAngle, sweepAngle);
16970
+ for (var i = 0; i < points.length; i = i + 8) {
16971
+ var point = [points[i], points[i + 1], points[i + 2], points[i + 3], points[i + 4], points[i + 5], points[i + 6], points[i + 7]];
16972
+ startFigure = this._addArcPoints(point, PathPointType.Bezier3, startFigure);
16973
+ }
16974
+ return startFigure;
16975
+ };
16976
+ PdfGraphics.prototype._addArcPoints = function (points, pointType, startFigure) {
16977
+ for (var i = 0; i < points.length; i++) {
16978
+ var point = new PointF(points[i], points[(i + 1)]);
16979
+ if (i === 0) {
16980
+ if (this._pathPoints.length === 0 || startFigure) {
16981
+ this._addPoint(point, PathPointType.Start);
16982
+ startFigure = false;
16983
+ }
16984
+ else if (point.x !== this._getLastPoint().x || point.y !== this._getLastPoint().y) {
16985
+ this._addPoint(point, PathPointType.Line);
16986
+ }
16987
+ }
16988
+ else {
16989
+ this._addPoint(point, pointType);
16990
+ }
16991
+ i++;
16992
+ }
16993
+ return startFigure;
16994
+ };
16995
+ PdfGraphics.prototype._getLastPoint = function () {
16996
+ var lastPoint = new PointF(0, 0);
16997
+ var count = this._pathPoints.length;
16998
+ if (count > 0) {
16999
+ lastPoint.x = this._pathPoints[(count - 1)].x;
17000
+ lastPoint.y = this._pathPoints[(count - 1)].y;
17001
+ }
17002
+ return lastPoint;
17003
+ };
17004
+ PdfGraphics.prototype._addPoint = function (point, type) {
17005
+ this._pathPoints.push(point);
17006
+ this._pathTypes.push(type);
17007
+ };
17008
+ PdfGraphics.prototype._getBezierArcPoints = function (x1, y1, x2, y2, s1, e1) {
17009
+ if ((x1 > x2)) {
17010
+ var tmp = void 0;
17011
+ tmp = x1;
17012
+ x1 = x2;
17013
+ x2 = tmp;
17014
+ }
17015
+ if ((y2 > y1)) {
17016
+ var tmp = void 0;
17017
+ tmp = y1;
17018
+ y1 = y2;
17019
+ y2 = tmp;
17020
+ }
17021
+ var fragAngle;
17022
+ var numFragments;
17023
+ if ((Math.abs(e1) <= 90)) {
17024
+ fragAngle = e1;
17025
+ numFragments = 1;
17026
+ }
17027
+ else {
17028
+ numFragments = (Math.ceil((Math.abs(e1) / 90)));
17029
+ fragAngle = (e1 / numFragments);
17030
+ }
17031
+ var xcen = ((x1 + x2) / 2);
17032
+ var ycen = ((y1 + y2) / 2);
17033
+ var rx = ((x2 - x1) / 2);
17034
+ var ry = ((y2 - y1) / 2);
17035
+ var halfAng = ((fragAngle * (Math.PI / 360)));
17036
+ var kappa = (Math.abs(4.0 / 3.0 * (1.0 - Math.cos(halfAng)) / Math.sin(halfAng)));
17037
+ var pointList = [];
17038
+ for (var i = 0; (i < numFragments); i++) {
17039
+ var theta0 = (((s1 + (i * fragAngle)) * (Math.PI / 180)));
17040
+ var theta1 = (((s1 + ((i + 1) * fragAngle)) * (Math.PI / 180)));
17041
+ var cos0 = (Math.cos(theta0));
17042
+ var cos1 = (Math.cos(theta1));
17043
+ var sin0 = (Math.sin(theta0));
17044
+ var sin1 = (Math.sin(theta1));
17045
+ if ((fragAngle > 0)) {
17046
+ pointList.push((xcen + (rx * cos0)), (ycen - (ry * sin0)), (xcen + (rx * (cos0 - (kappa * sin0)))), (ycen - (ry * (sin0 + (kappa * cos0)))), (xcen + (rx * (cos1 + (kappa * sin1)))), (ycen - (ry * (sin1 - (kappa * cos1)))), (xcen + (rx * cos1)), (ycen - (ry * sin1)));
17047
+ }
17048
+ else {
17049
+ pointList.push((xcen + (rx * cos0)), (ycen - (ry * sin0)), (xcen + (rx * (cos0 + (kappa * sin0)))), (ycen - (ry * (sin0 - (kappa * cos0)))), (xcen + (rx * (cos1 - (kappa * sin1)))), (ycen - (ry * (sin1 + (kappa * cos1)))), (xcen + (rx * cos1)), (ycen - (ry * sin1)));
17050
+ }
17051
+ }
17052
+ return pointList;
17053
+ };
16910
17054
  PdfGraphics.prototype.drawPathHelper = function (arg1, arg2, arg3, arg4) {
16911
17055
  if (typeof arg3 === 'boolean') {
16912
17056
  var temparg3 = arg3;
@@ -16931,7 +17075,6 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
16931
17075
  }
16932
17076
  }
16933
17077
  };
16934
- /* tslint:disable */
16935
17078
  PdfGraphics.prototype.drawImage = function (arg1, arg2, arg3, arg4, arg5) {
16936
17079
  if (typeof arg2 === 'number' && typeof arg3 === 'number' && typeof arg4 === 'undefined') {
16937
17080
  var size = arg1.physicalDimension;
@@ -16967,7 +17110,6 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
16967
17110
  }
16968
17111
  };
16969
17112
  //Implementation
16970
- /* tslint:disable */
16971
17113
  /**
16972
17114
  * Returns `bounds` of the line info.
16973
17115
  * @private
@@ -16983,8 +17125,7 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
16983
17125
  var lineIndent = this.getLineIndent(line, format, layoutRectangle, (lineIndex === 0));
16984
17126
  hShift += (!this.rightToLeft(format)) ? lineIndent : 0;
16985
17127
  var x = layoutRectangle.x + hShift;
16986
- /* tslint:disable */
16987
- var width = (!this.shouldJustify(line, layoutRectangle.width, format)) ? lineWidth - lineIndent : layoutRectangle.width - lineIndent; /* tslint:enable */
17128
+ var width = (!this.shouldJustify(line, layoutRectangle.width, format)) ? lineWidth - lineIndent : layoutRectangle.width - lineIndent;
16988
17129
  var height = result.lineHeight;
16989
17130
  bounds = new RectangleF(x, y, width, height);
16990
17131
  }
@@ -17034,7 +17175,6 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
17034
17175
  * Adding page number field before page saving.
17035
17176
  * @private
17036
17177
  */
17037
- /* tslint:disable */
17038
17178
  PdfGraphics.prototype.pageSave = function (page) {
17039
17179
  if (page.graphics.automaticFields != null) {
17040
17180
  for (var i = 0; i < page.graphics.automaticFields.automaticFields.length; i++) {
@@ -17166,7 +17306,6 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
17166
17306
  }
17167
17307
  return shift;
17168
17308
  };
17169
- /* tslint:disable */
17170
17309
  /**
17171
17310
  * `Draws layout result`.
17172
17311
  * @private
@@ -17293,9 +17432,7 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
17293
17432
  /**
17294
17433
  * Draws array of unicode tokens.
17295
17434
  */
17296
- /* tslint:disable */
17297
17435
  PdfGraphics.prototype.drawUnicodeBlocks = function (blocks, words, font, format, wordSpacing) {
17298
- /* tslint:enable */
17299
17436
  if (blocks == null) {
17300
17437
  throw new Error('Argument Null Exception : blocks');
17301
17438
  }
@@ -17455,11 +17592,9 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
17455
17592
  var whitespacesCount = StringTokenizer.getCharsCount(line, symbols);
17456
17593
  var hasSpaces = (whitespacesCount > 0 && line[0] !== StringTokenizer.whiteSpace);
17457
17594
  var goodLineBreakStyle = ((lineInfo.lineType & LineType.LayoutBreak) > 0);
17458
- /* tslint:disable */
17459
- var shouldJustify = (justifyStyle && goodWidth && hasSpaces && (goodLineBreakStyle || format.alignment === PdfTextAlignment.Justify)); /* tslint:enable */
17595
+ var shouldJustify = (justifyStyle && goodWidth && hasSpaces && (goodLineBreakStyle || format.alignment === PdfTextAlignment.Justify));
17460
17596
  return shouldJustify;
17461
17597
  };
17462
- /* tslint:disable */
17463
17598
  /**
17464
17599
  * Emulates `Underline, Strikeout` of the text if needed.
17465
17600
  * @private
@@ -17484,9 +17619,7 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
17484
17619
  var lineIndent = this.getLineIndent(lineInfo, format, layoutRectangle, (i === 0));
17485
17620
  hShift += (!this.rightToLeft(format)) ? lineIndent : 0;
17486
17621
  var x1 = layoutRectangle.x + hShift;
17487
- /* tslint:disable */
17488
17622
  var x2 = (!this.shouldJustify(lineInfo, layoutRectangle.width, format)) ? x1 + lineWidth - lineIndent : x1 + layoutRectangle.width - lineIndent;
17489
- /* tslint:enable */
17490
17623
  if (font.underline) {
17491
17624
  var y = underlineYOffset;
17492
17625
  this.drawLine(linePen, x1, y, x2, y);
@@ -17615,7 +17748,6 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
17615
17748
  }
17616
17749
  else if (pen != null) {
17617
17750
  if (typeof this.pageLayer !== 'undefined' && this.pageLayer != null) {
17618
- /* tslint:disable */
17619
17751
  this.colorSpace = this.pageLayer.page.document.colorSpace;
17620
17752
  this.currentColorSpace = this.pageLayer.page.document.colorSpace;
17621
17753
  }
@@ -17652,9 +17784,7 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
17652
17784
  PdfGraphics.prototype.penControl = function (pen, saveState) {
17653
17785
  if (pen != null) {
17654
17786
  this.currentPen = pen;
17655
- /* tslint:disable */
17656
17787
  pen.monitorChanges(this.currentPen, this.pdfStreamWriter, this.getResources, saveState, this.colorSpace, this.matrix.clone());
17657
- /* tslint:enable */
17658
17788
  this.currentPen = pen.clone();
17659
17789
  }
17660
17790
  };
@@ -17677,7 +17807,6 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
17677
17807
  }
17678
17808
  this.currentBrush = lgb;
17679
17809
  b.monitorChanges(this.currentBrush, this.pdfStreamWriter, this.getResources, saveState, this.colorSpace);
17680
- /* tslint:enable */
17681
17810
  this.currentBrush = brush;
17682
17811
  brush = null;
17683
17812
  }
@@ -17689,14 +17818,12 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
17689
17818
  PdfGraphics.prototype.fontControl = function (font, format, saveState) {
17690
17819
  if (font != null) {
17691
17820
  var curSubSuper = (format != null) ? format.subSuperScript : PdfSubSuperScript.None;
17692
- /* tslint:disable */
17693
- var prevSubSuper = (this.currentStringFormat != null) ? this.currentStringFormat.subSuperScript : PdfSubSuperScript.None; /* tslint:enable */
17821
+ var prevSubSuper = (this.currentStringFormat != null) ? this.currentStringFormat.subSuperScript : PdfSubSuperScript.None;
17694
17822
  if (saveState || font !== this.currentFont || curSubSuper !== prevSubSuper) {
17695
17823
  var resources = this.getResources.getResources();
17696
17824
  this.currentFont = font;
17697
17825
  this.currentStringFormat = format;
17698
17826
  var size = font.metrics.getSize(format);
17699
- /* tslint:disable */
17700
17827
  this.isEmfTextScaled = false;
17701
17828
  var fontName = resources.getName(font);
17702
17829
  this.pdfStreamWriter.setFont(font, fontName, size);
@@ -17795,7 +17922,6 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
17795
17922
  input.translate(x, this.updateY(y));
17796
17923
  return input;
17797
17924
  };
17798
- /* tslint:disable */
17799
17925
  /**
17800
17926
  * Applies the specified `scaling operation` to the transformation matrix of this Graphics by prepending it to the object's transformation matrix.
17801
17927
  * ```typescript
@@ -17819,7 +17945,6 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
17819
17945
  * @param scaleX Scale factor in the x direction.
17820
17946
  * @param scaleY Scale factor in the y direction.
17821
17947
  */
17822
- /* tslint:enable */
17823
17948
  PdfGraphics.prototype.scaleTransform = function (scaleX, scaleY) {
17824
17949
  var matrix = new PdfTransformationMatrix();
17825
17950
  this.getScaleTransform(scaleX, scaleY, matrix);
@@ -17971,7 +18096,6 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
17971
18096
  this.pdfStreamWriter.restoreGraphicsState();
17972
18097
  return state;
17973
18098
  };
17974
- /* tslint:enable */
17975
18099
  /**
17976
18100
  * `Draws the specified path`, using its original physical size, at the location specified by a coordinate pair.
17977
18101
  * ```typescript
@@ -18002,6 +18126,9 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
18002
18126
  * @param path Draw path.
18003
18127
  */
18004
18128
  PdfGraphics.prototype.drawPath = function (pen, brush, path) {
18129
+ this._drawPath(pen, brush, path.pathPoints, path.pathTypes, path.fillMode);
18130
+ };
18131
+ PdfGraphics.prototype._drawPath = function (pen, brush, pathPoints, pathTypes, fillMode) {
18005
18132
  if (brush instanceof PdfTilingBrush) {
18006
18133
  this.bCSInitialized = false;
18007
18134
  brush.graphics.colorSpace = this.colorSpace;
@@ -18011,8 +18138,8 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
18011
18138
  brush.colorSpace = this.colorSpace;
18012
18139
  }
18013
18140
  this.stateControl(pen, brush, null);
18014
- this.buildUpPath(path.pathPoints, path.pathTypes);
18015
- this.drawPathHelper(pen, brush, path.fillMode, false);
18141
+ this.buildUpPath(pathPoints, pathTypes);
18142
+ this.drawPathHelper(pen, brush, fillMode, false);
18016
18143
  };
18017
18144
  /* tslint:disable-next-line:max-line-length */
18018
18145
  PdfGraphics.prototype.drawArc = function (arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
@@ -18157,6 +18284,7 @@ var PdfGraphics = /** @__PURE__ @class */ (function () {
18157
18284
  }
18158
18285
  return pointsList;
18159
18286
  };
18287
+ /* tslint:disable */
18160
18288
  // Constants
18161
18289
  /**
18162
18290
  * Specifies the mask of `path type values`.
@@ -18386,6 +18514,7 @@ var TransparencyData = /** @__PURE__ @class */ (function () {
18386
18514
  }
18387
18515
  return TransparencyData;
18388
18516
  }());
18517
+ /* tslint:enable */
18389
18518
 
18390
18519
  /**
18391
18520
  * The `PdfPageLayer` used to create layers in PDF document.