jspdf-dynamo 1.0.5 → 1.0.7

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.
Files changed (36) hide show
  1. package/README.md +3 -3
  2. package/dist/index.cjs +199 -33
  3. package/dist/index.d.cts +14 -10
  4. package/dist/index.d.ts +14 -10
  5. package/dist/index.js +199 -33
  6. package/documentation/1. Introduction/Introduction.txt +1 -1
  7. package/documentation/3. Variables/Introduction.txt +13 -12
  8. package/documentation/3. Variables/SystemMaintained.txt +40 -0
  9. package/documentation/4. Commands/DrawBox.txt +6 -9
  10. package/documentation/4. Commands/DrawCircle.txt +71 -0
  11. package/documentation/4. Commands/DrawEllipse.txt +75 -0
  12. package/documentation/4. Commands/DrawTextWrapped.txt +1 -1
  13. package/documentation/4. Commands/IfBlank.txt +9 -14
  14. package/documentation/4. Commands/IfEq.txt +3 -2
  15. package/documentation/4. Commands/IfGt.txt +2 -1
  16. package/documentation/4. Commands/IfNe.txt +54 -0
  17. package/documentation/4. Commands/IfNotBlank.txt +9 -13
  18. package/documentation/4. Commands/LoadImageFromFile.txt +2 -2
  19. package/documentation/4. Commands/LoadImageFromUrl.txt +2 -2
  20. package/documentation/4. Commands/SetFillColour.txt +4 -2
  21. package/documentation/4. Commands/SetFontName.txt +80 -1
  22. package/documentation/4. Commands/SetFontSize.txt +43 -1
  23. package/documentation/4. Commands/SetFontStyle.txt +4 -5
  24. package/documentation/4. Commands/SetLineColour.txt +5 -2
  25. package/documentation/4. Commands/SetTextColour.txt +4 -2
  26. package/documentation/5. Other Definitions/pageSizes.txt +3 -3
  27. package/documentation/Documentation.pdf +0 -0
  28. package/documentation/documentation.txt +3 -0
  29. package/examples/1.Simple/simple.pdf +18 -186
  30. package/examples/2.Invoice/data.txt +21 -0
  31. package/examples/2.Invoice/gearz.png +0 -0
  32. package/examples/2.Invoice/invoice.pdf +0 -0
  33. package/examples/2.Invoice/invoice.spec.ts +62 -0
  34. package/examples/2.Invoice/parts.json +324 -0
  35. package/examples/2.Invoice/template.txt +136 -0
  36. package/package.json +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@ jsPdf-Dynamo is a wrapper around the open-source JavaScript PDF generation libra
4
4
  template driven approach, it enables the separation of layout and formatting logic from the placement of
5
5
  data.
6
6
 
7
- jsPdf-Dynamo can be used with browser or NodeJs JavaScript or TypeScript applications.
7
+ jsPdf-Dynamo can be used with browser or NodeJs applications written in JavaScript or TypeScript.
8
8
 
9
9
  Advantages of using jsPdf-Dynamo include:
10
10
 
@@ -31,8 +31,8 @@ yarn add jspdf
31
31
  There are a few basic concepts to be aware of when using jsPdf-Dynamo:
32
32
 
33
33
  - The functionality of jsPdf-Dynamo is implemented through the JsPdfDynamo class.
34
- - The initial page size, orientation and units of measure are set when the JsPdfDynamo instance is instantiated.
35
- - Output is driven by a series of plain text 'commands'. These commands can be provided as a list of strings from multiple sources, including the JavaScript or TypeScript application, or loaded from 'templates' retrieved from a URL (browser or NodeJs) or from local text files (NodeJs only).
34
+ - The initial page size, orientation and unit of measure are set when the JsPdfDynamo instance is instantiated.
35
+ - Output is driven by a series of plain text 'commands'. These commands can be provided as a list of strings from multiple sources, including the JavaScript or TypeScript application, or loaded from 'templates' retrieved from a URL (browser only) or from local text files (NodeJs only).
36
36
  - Positions are specified relative to the left and top margin. The exception to this are margins which are measured from the appropriate edge of the page.
37
37
  - All measurements and positions are in the unit of measure specified when the instance
38
38
  of JsPdfDynamo is created. This can be millimeters, inches, or points. The exception to this are fonts, which are always specified in points.
package/dist/index.cjs CHANGED
@@ -75,19 +75,19 @@ var AppLogger = class {
75
75
  this._logger = console;
76
76
  }
77
77
  }
78
- trace(message, ...args) {
78
+ trace(message, args) {
79
79
  this.canLog(0) ? this._logger.trace(message, args) : null;
80
80
  }
81
- debug(message, ...args) {
81
+ debug(message, args) {
82
82
  this.canLog(1) ? this._logger.debug(message, args) : null;
83
83
  }
84
- info(message, ...args) {
84
+ info(message, args) {
85
85
  this.canLog(2) ? this._logger.info(message, args) : null;
86
86
  }
87
- warn(message, ...args) {
87
+ warn(message, args) {
88
88
  this.canLog(3) ? this._logger.warn(message, args) : null;
89
89
  }
90
- error(message, ...args) {
90
+ error(message, args) {
91
91
  this.canLog(4) ? this._logger.error(message, args) : null;
92
92
  }
93
93
  logLevel(newLevel) {
@@ -264,6 +264,8 @@ function isValidFontStyle(fontStyle) {
264
264
  // src/models/jsPdfOptions.ts
265
265
  var JsPdfOptions = class {
266
266
  constructor(options = {}) {
267
+ this.compress = true;
268
+ this.putOnlyUsedFonts = true;
267
269
  var _a, _b, _c;
268
270
  this.pageSize = ((_a = options.pageSize) == null ? void 0 : _a.toLocaleLowerCase()) || "a4";
269
271
  this.orientation = ((_b = options.orientation) == null ? void 0 : _b.toLocaleLowerCase()) || "portrait";
@@ -343,15 +345,32 @@ var JsPdfProcessor = class {
343
345
  this.pageOrientation = optn.orientation;
344
346
  this.currentUom = optn.unit;
345
347
  this._pdfDocument.setLineHeightFactor(1);
348
+ const now = /* @__PURE__ */ new Date();
346
349
  this._variables.set(
347
350
  "_TIMEHM",
348
- (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
351
+ now.toLocaleTimeString(void 0, {
349
352
  hour12: false,
350
353
  hour: "2-digit",
351
354
  minute: "2-digit"
352
355
  })
353
356
  );
354
- this._variables.set("_DATEDMY", (/* @__PURE__ */ new Date()).toLocaleDateString("en-GB"));
357
+ this._variables.set(
358
+ "_DATEDDMMYYYY",
359
+ now.toLocaleDateString("en-GB", {
360
+ day: "2-digit",
361
+ month: "2-digit",
362
+ year: "numeric"
363
+ })
364
+ );
365
+ this._variables.set(
366
+ "_DATEMMDDYYYY",
367
+ now.toLocaleDateString("en-US", {
368
+ day: "2-digit",
369
+ month: "2-digit",
370
+ year: "numeric"
371
+ })
372
+ );
373
+ this._variables.set("_DATEISO", now.toISOString().substring(0, 10));
355
374
  this._variables.set("_IMAGEASPECT", "1");
356
375
  this._variables.set("_IMAGEHEIGHT", "0");
357
376
  this._variables.set("_IMAGEHEIGHTPX", "0");
@@ -823,6 +842,16 @@ var JsPdfProcessor = class {
823
842
  if (!this.checkPosition(left, top)) {
824
843
  return;
825
844
  }
845
+ if (isNaN(width)) {
846
+ this.lastError = `The width of the box is not a number`;
847
+ this.lastResult = "0";
848
+ return;
849
+ }
850
+ if (isNaN(height)) {
851
+ this.lastError = `The height of the box is not a number`;
852
+ this.lastResult = "0";
853
+ return;
854
+ }
826
855
  this.posnX = left;
827
856
  this.posnY = top;
828
857
  let lineWidthAdjustment = this._lineWidth;
@@ -843,6 +872,10 @@ var JsPdfProcessor = class {
843
872
  style = "FD";
844
873
  this._pdfDocument.setFillColor(this.fillColour);
845
874
  break;
875
+ default:
876
+ this.lastError = `The box style option '${boxType}' is not valid. It must be '0', '1' or '2'`;
877
+ this.lastResult = "0";
878
+ return;
846
879
  }
847
880
  this._pdfDocument.rect(x, y, w, h, style);
848
881
  this.posnX = this.posnX + width + this.spaceHoz;
@@ -851,10 +884,57 @@ var JsPdfProcessor = class {
851
884
  this.lastObjectWidth = width;
852
885
  this.lastResult = "1";
853
886
  }
887
+ drawCircle(input) {
888
+ const subs = this.logAndParseCommand(".drawCircle", input);
889
+ const { first: left, rest: rest1 } = getNextNumber(subs);
890
+ const { first: top, rest: rest2 } = getNextNumber(rest1);
891
+ const { first: radius, rest: rest3 } = getNextNumber(rest2);
892
+ const { first: option } = getNextNumber(rest3);
893
+ if (!this.checkPosition(left, top)) {
894
+ return;
895
+ }
896
+ if (isNaN(radius)) {
897
+ this.lastError = `The radius of the circle is not a number`;
898
+ this.lastResult = "0";
899
+ return;
900
+ }
901
+ this.posnX = left;
902
+ this.posnY = top;
903
+ const x = this.posnX + this._marginLeft;
904
+ const y = this.posnY + this._marginTop;
905
+ let r = radius;
906
+ let style = "S";
907
+ switch (option) {
908
+ case 0:
909
+ r -= this._lineWidth * 0.5;
910
+ break;
911
+ case 1:
912
+ style = "F";
913
+ this._pdfDocument.setFillColor(this.fillColour);
914
+ break;
915
+ case 2:
916
+ style = "FD";
917
+ this._pdfDocument.setFillColor(this.fillColour);
918
+ r -= this._lineWidth * 0.5;
919
+ break;
920
+ default:
921
+ this.lastError = `The circle style option '${option}' is not valid. It must be '0', '1' or '2'`;
922
+ this.lastResult = "0";
923
+ return;
924
+ }
925
+ this._pdfDocument.circle(x, y, r, style);
926
+ this.lastObjectHeight = radius * 2;
927
+ this.lastObjectWidth = this.lastObjectHeight;
928
+ this.posnX = this.posnX + radius + this.spaceHoz;
929
+ this.posnY = this.posnY + radius + this.spaceVert;
930
+ this.lastResult = "1";
931
+ }
854
932
  drawDebugGrid(input) {
855
933
  const subs = this.logAndParseCommand(".drawDebugGrid", input);
856
934
  const savedLineColour = this.lineColour;
857
935
  const savedLineWidth = this.lineWidth;
936
+ const savedX = this.posnX;
937
+ const savedY = this.posnY;
858
938
  const mm = 0.1;
859
939
  const pts = mmToPoints(mm);
860
940
  const lineWidth = this.pointsToUom(pts);
@@ -911,6 +991,62 @@ var JsPdfProcessor = class {
911
991
  }
912
992
  this.lineColour = savedLineColour;
913
993
  this.lineWidth = savedLineWidth;
994
+ this.posnX = savedX;
995
+ this.posnY = savedY;
996
+ }
997
+ drawEllipse(input) {
998
+ const subs = this.logAndParseCommand(".drawEllipse", input);
999
+ const { first: left, rest: rest1 } = getNextNumber(subs);
1000
+ const { first: top, rest: rest2 } = getNextNumber(rest1);
1001
+ const { first: radiusX, rest: rest3 } = getNextNumber(rest2);
1002
+ const { first: radiusY, rest: rest4 } = getNextNumber(rest3);
1003
+ const { first: option } = getNextNumber(rest4);
1004
+ if (!this.checkPosition(left, top)) {
1005
+ return;
1006
+ }
1007
+ if (isNaN(radiusX)) {
1008
+ this.lastError = `The horizontal radius of the ellipse is not a number`;
1009
+ this.lastResult = "0";
1010
+ return;
1011
+ }
1012
+ if (isNaN(radiusY)) {
1013
+ this.lastError = `The vertical radius of the ellipse is not a number`;
1014
+ this.lastResult = "0";
1015
+ return;
1016
+ }
1017
+ this.posnX = left;
1018
+ this.posnY = top;
1019
+ const x = this.posnX + this._marginLeft;
1020
+ const y = this.posnY + this._marginTop;
1021
+ let rx = radiusX;
1022
+ let ry = radiusY;
1023
+ let style = "S";
1024
+ switch (option) {
1025
+ case 0:
1026
+ rx -= this._lineWidth * 0.5;
1027
+ ry -= this._lineWidth * 0.5;
1028
+ break;
1029
+ case 1:
1030
+ style = "F";
1031
+ this._pdfDocument.setFillColor(this.fillColour);
1032
+ break;
1033
+ case 2:
1034
+ style = "FD";
1035
+ this._pdfDocument.setFillColor(this.fillColour);
1036
+ rx -= this._lineWidth * 0.5;
1037
+ ry -= this._lineWidth * 0.5;
1038
+ break;
1039
+ default:
1040
+ this.lastError = `The circle style option '${option}' is not valid. It must be '0', '1' or '2'`;
1041
+ this.lastResult = "0";
1042
+ return;
1043
+ }
1044
+ this._pdfDocument.ellipse(x, y, rx, ry, style);
1045
+ this.lastObjectHeight = radiusY * 2;
1046
+ this.lastObjectWidth = radiusX * 2;
1047
+ this.posnX = this.posnX + radiusX + this.spaceHoz;
1048
+ this.posnY = this.posnY + radiusY + this.spaceVert;
1049
+ this.lastResult = "1";
914
1050
  }
915
1051
  drawLine(input) {
916
1052
  const subs = this.logAndParseCommand(".drawLine", input);
@@ -950,7 +1086,7 @@ var JsPdfProcessor = class {
950
1086
  return;
951
1087
  }
952
1088
  if (isNaN(imageNo) || imageNo < 0 || imageNo > this._images.length - 1) {
953
- this.lastError = this._images.length ? "The image number must be in the range of 0 to " + (this._images.length - 1).toString() : "Only one image has been loaded, the image number can only be 0";
1089
+ this.lastError = this._images.length > 1 ? `The image number ${imageNo} must be in the range of 0 to ${(this._images.length - 1).toString()}` : "Only one image has been loaded, the image number can only be 0";
954
1090
  this.lastResult = "0";
955
1091
  return;
956
1092
  }
@@ -1001,7 +1137,6 @@ var JsPdfProcessor = class {
1001
1137
  this.lastResult = "1";
1002
1138
  }
1003
1139
  drawText(input) {
1004
- var _a;
1005
1140
  const subs = this.logAndParseCommand(".drawText", input);
1006
1141
  const { first: left, rest: rest1 } = getNextNumber(subs);
1007
1142
  const { first: top, rest: rest2 } = getNextNumber(rest1);
@@ -1013,7 +1148,7 @@ var JsPdfProcessor = class {
1013
1148
  this.lastObjectWidth = 0;
1014
1149
  this.lastResult = "1";
1015
1150
  if (lines.length > 1) {
1016
- this.lastError = `Text was truncated to fit within the available width (${(_a = lines[0]) == null ? void 0 : _a.substring(0, 20)}...)`;
1151
+ this.lastError = `Text was truncated to fit within the available width (${rest2.substring(0, 20)}...) on page ${this._currentPageNumber}.`;
1017
1152
  this.lastResult = "0";
1018
1153
  if (lines[0]) {
1019
1154
  if (this._pdfDocument.getTextWidth(lines[0]) < maxWidth) {
@@ -1319,10 +1454,11 @@ var JsPdfProcessor = class {
1319
1454
  }
1320
1455
  ifNotBlank(jsPdfDynamo, input) {
1321
1456
  return __async(this, null, function* () {
1322
- let { first: variable, rest } = getNextString(input);
1457
+ let { first: value1, rest } = getNextString(input);
1323
1458
  const subs = this.substitute(rest.trim());
1324
- this._logger.debug(".ifNotBlank " + variable + " " + subs);
1325
- let value = this._variables.get(variable.toLocaleUpperCase()) || "";
1459
+ this._logger.debug(".ifNotBlank " + value1 + " " + subs);
1460
+ const variable1 = this.substitute(value1);
1461
+ let value = this._variables.get(variable1.toLocaleUpperCase()) || "";
1326
1462
  this.lastResult = "-1";
1327
1463
  if (value.trim() !== "") {
1328
1464
  yield jsPdfDynamo.processDot(this, rest);
@@ -1576,9 +1712,14 @@ var JsPdfProcessor = class {
1576
1712
  }
1577
1713
  }
1578
1714
  setFillColour(input) {
1579
- let subs = this.substitute(input);
1580
- this._logger.debug(".setFillColour " + subs);
1581
- this.fillColour = subs;
1715
+ const subs = this.logAndParseCommand(".setFillColour", input);
1716
+ const { first: fillColour } = getNextString(subs);
1717
+ if (fillColour === "") {
1718
+ this.lastResult = "0";
1719
+ this.lastError = "A fill colour must be specified";
1720
+ return;
1721
+ }
1722
+ this.fillColour = fillColour;
1582
1723
  this.lastResult = "1";
1583
1724
  }
1584
1725
  setFontName(input) {
@@ -1594,14 +1735,25 @@ var JsPdfProcessor = class {
1594
1735
  }
1595
1736
  setFontSize(input) {
1596
1737
  const subs = this.logAndParseCommand(".setFontSize", input);
1597
- let { first: size } = getNextNumber(subs);
1598
- if (size > 0) {
1599
- this.fontPointSize = size;
1600
- this.lastResult = "1";
1601
- } else {
1738
+ if (subs === "") {
1602
1739
  this.lastResult = "0";
1603
- this.lastError = "Invalid font size " + size;
1740
+ this.lastError = "A font size must be specified";
1741
+ return;
1604
1742
  }
1743
+ let { first: sizeAlpha } = getNextNumber(subs);
1744
+ const size = Number(sizeAlpha);
1745
+ if (Number.isNaN(size)) {
1746
+ this.lastResult = "0";
1747
+ this.lastError = `A font size must be a number. '${sizeAlpha}' is not a number.`;
1748
+ return;
1749
+ }
1750
+ if (size <= 0) {
1751
+ this.lastResult = "0";
1752
+ this.lastError = "A font size must be greater than 0";
1753
+ return;
1754
+ }
1755
+ this.fontPointSize = size;
1756
+ this.lastResult = "1";
1605
1757
  }
1606
1758
  setFontStyle(input) {
1607
1759
  const subs = this.logAndParseCommand(".setFontStyle", input);
@@ -1620,9 +1772,14 @@ var JsPdfProcessor = class {
1620
1772
  this.lastResult = "1";
1621
1773
  }
1622
1774
  setLineColour(input) {
1623
- let subs = this.substitute(input);
1624
- this._logger.debug(".setLineColour " + subs);
1625
- this.lineColour = subs;
1775
+ const subs = this.logAndParseCommand(".setFontStyle", input);
1776
+ const { first: lineColour } = getNextString(subs);
1777
+ if (lineColour === "") {
1778
+ this.lastResult = "0";
1779
+ this.lastError = "A line colour must be specified";
1780
+ return;
1781
+ }
1782
+ this.lineColour = lineColour;
1626
1783
  this.lastResult = "1";
1627
1784
  }
1628
1785
  setLineWidth(input) {
@@ -1728,7 +1885,13 @@ var JsPdfProcessor = class {
1728
1885
  }
1729
1886
  setTextColour(input) {
1730
1887
  const subs = this.logAndParseCommand(".setTextColour", input);
1731
- this.textColour = subs;
1888
+ const { first: textColour } = getNextString(subs);
1889
+ if (textColour === "") {
1890
+ this.lastResult = "0";
1891
+ this.lastError = "A text colour must be specified";
1892
+ return;
1893
+ }
1894
+ this.textColour = textColour;
1732
1895
  this.lastResult = "1";
1733
1896
  }
1734
1897
  copyVar(input) {
@@ -1942,10 +2105,6 @@ var JsPdfDynamo = class {
1942
2105
  if (currLine.startsWith("[")) {
1943
2106
  if (inGroupLoading) {
1944
2107
  inGroupLoading = false;
1945
- __privateGet(this, _appLogger).debug(
1946
- `Finished loading group ${grpName} (${currLine})
1947
- `
1948
- );
1949
2108
  } else {
1950
2109
  if (currLine.length === 1) continue;
1951
2110
  grpName = currLine.substring(1);
@@ -1955,8 +2114,7 @@ var JsPdfDynamo = class {
1955
2114
  }
1956
2115
  grpName = grpName.trim().toLocaleUpperCase();
1957
2116
  inGroupLoading = true;
1958
- __privateGet(this, _appLogger).debug(`Loading group ${grpName} (${currLine})
1959
- `);
2117
+ __privateGet(this, _appLogger).debug(`Loading group ${grpName}`);
1960
2118
  currGroup = [];
1961
2119
  __privateGet(this, _groups)[grpName] = currGroup;
1962
2120
  }
@@ -2007,9 +2165,15 @@ var JsPdfDynamo = class {
2007
2165
  case "DrawBox".toLowerCase():
2008
2166
  processor.drawBox(parameters);
2009
2167
  return;
2168
+ case "DrawCircle".toLowerCase():
2169
+ processor.drawCircle(parameters);
2170
+ return;
2010
2171
  case "DrawDebugGrid".toLowerCase():
2011
2172
  processor.drawDebugGrid(parameters);
2012
2173
  return;
2174
+ case "DrawEllipse".toLowerCase():
2175
+ processor.drawEllipse(parameters);
2176
+ return;
2013
2177
  case "DrawImage".toLowerCase():
2014
2178
  processor.drawImage(parameters);
2015
2179
  return;
@@ -2140,9 +2304,11 @@ var JsPdfDynamo = class {
2140
2304
  let { first: group, rest } = getNextString(subs);
2141
2305
  subs = rest;
2142
2306
  __privateGet(this, _appLogger).debug(`
2143
- [${group}]`);
2307
+ [${group} - Enter]`);
2144
2308
  if (__privateGet(this, _groups)[group]) {
2145
2309
  yield this.processTemplate(processor, __privateGet(this, _groups)[group]);
2310
+ __privateGet(this, _appLogger).debug(`[${group} - Exit]
2311
+ `);
2146
2312
  } else {
2147
2313
  __privateGet(this, _appLogger).warn(`Group ${group} was not found.`);
2148
2314
  processor.lastResult = "0";
package/dist/index.d.cts CHANGED
@@ -1,21 +1,21 @@
1
1
  import jsPDF from 'jspdf';
2
2
 
3
3
  interface ILogger {
4
- debug: (message: string, ...args: any | null) => void;
5
- error: (message: string, ...args: any | null) => void;
6
- info: (message: string, ...args: any | null) => void;
7
- trace: (message: string, ...args: any | null) => void;
8
- warn: (message: string, ...args: any | null) => void;
4
+ debug: (message: string, args?: any) => void;
5
+ error: (message: string, args?: any) => void;
6
+ info: (message: string, args?: any) => void;
7
+ trace: (message: string, args?: any) => void;
8
+ warn: (message: string, args?: any) => void;
9
9
  }
10
10
  declare class AppLogger implements ILogger {
11
11
  private _logLevel;
12
12
  private _logger;
13
13
  constructor(logger?: ILogger | null);
14
- trace(message: string, ...args: any | null): void;
15
- debug(message: string, ...args: any | null): void;
16
- info(message: string, ...args: any | null): void;
17
- warn(message: string, ...args: any | null): void;
18
- error(message: string, ...args: any | null): void;
14
+ trace(message: string, args?: any): void;
15
+ debug(message: string, args?: any): void;
16
+ info(message: string, args?: any): void;
17
+ warn(message: string, args?: any): void;
18
+ error(message: string, args?: any): void;
19
19
  logLevel(newLevel: string | number): void;
20
20
  private canLog;
21
21
  }
@@ -193,6 +193,7 @@ declare const pageSizes: {
193
193
  type pageSizeType = keyof typeof pageSizes;
194
194
 
195
195
  interface IJsPdfOptions {
196
+ compress: boolean;
196
197
  margins: {
197
198
  top: number;
198
199
  bottom: number;
@@ -200,6 +201,7 @@ interface IJsPdfOptions {
200
201
  right: number;
201
202
  };
202
203
  pageSize: pageSizeType;
204
+ putOnlyUsedFonts: boolean;
203
205
  orientation: "portrait" | "landscape" | "p" | "l";
204
206
  unit: "mm" | "in" | "pt";
205
207
  }
@@ -313,7 +315,9 @@ declare class JsPdfProcessor {
313
315
  private getContentType;
314
316
  checkPage(jsPdfDynamo: JsPdfDynamo, input: string): Promise<void>;
315
317
  drawBox(input: string): void;
318
+ drawCircle(input: string): void;
316
319
  drawDebugGrid(input: string): void;
320
+ drawEllipse(input: string): void;
317
321
  drawLine(input: string): void;
318
322
  drawImage(input: string): void;
319
323
  drawText(input: string): void;
package/dist/index.d.ts CHANGED
@@ -1,21 +1,21 @@
1
1
  import jsPDF from 'jspdf';
2
2
 
3
3
  interface ILogger {
4
- debug: (message: string, ...args: any | null) => void;
5
- error: (message: string, ...args: any | null) => void;
6
- info: (message: string, ...args: any | null) => void;
7
- trace: (message: string, ...args: any | null) => void;
8
- warn: (message: string, ...args: any | null) => void;
4
+ debug: (message: string, args?: any) => void;
5
+ error: (message: string, args?: any) => void;
6
+ info: (message: string, args?: any) => void;
7
+ trace: (message: string, args?: any) => void;
8
+ warn: (message: string, args?: any) => void;
9
9
  }
10
10
  declare class AppLogger implements ILogger {
11
11
  private _logLevel;
12
12
  private _logger;
13
13
  constructor(logger?: ILogger | null);
14
- trace(message: string, ...args: any | null): void;
15
- debug(message: string, ...args: any | null): void;
16
- info(message: string, ...args: any | null): void;
17
- warn(message: string, ...args: any | null): void;
18
- error(message: string, ...args: any | null): void;
14
+ trace(message: string, args?: any): void;
15
+ debug(message: string, args?: any): void;
16
+ info(message: string, args?: any): void;
17
+ warn(message: string, args?: any): void;
18
+ error(message: string, args?: any): void;
19
19
  logLevel(newLevel: string | number): void;
20
20
  private canLog;
21
21
  }
@@ -193,6 +193,7 @@ declare const pageSizes: {
193
193
  type pageSizeType = keyof typeof pageSizes;
194
194
 
195
195
  interface IJsPdfOptions {
196
+ compress: boolean;
196
197
  margins: {
197
198
  top: number;
198
199
  bottom: number;
@@ -200,6 +201,7 @@ interface IJsPdfOptions {
200
201
  right: number;
201
202
  };
202
203
  pageSize: pageSizeType;
204
+ putOnlyUsedFonts: boolean;
203
205
  orientation: "portrait" | "landscape" | "p" | "l";
204
206
  unit: "mm" | "in" | "pt";
205
207
  }
@@ -313,7 +315,9 @@ declare class JsPdfProcessor {
313
315
  private getContentType;
314
316
  checkPage(jsPdfDynamo: JsPdfDynamo, input: string): Promise<void>;
315
317
  drawBox(input: string): void;
318
+ drawCircle(input: string): void;
316
319
  drawDebugGrid(input: string): void;
320
+ drawEllipse(input: string): void;
317
321
  drawLine(input: string): void;
318
322
  drawImage(input: string): void;
319
323
  drawText(input: string): void;