jspdf-dynamo 1.0.0 → 1.0.1

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/index.cjs CHANGED
@@ -61,9 +61,6 @@ __export(src_exports, {
61
61
  });
62
62
  module.exports = __toCommonJS(src_exports);
63
63
 
64
- // src/jsPdfDynamo.ts
65
- var import_node_fetch = __toESM(require("node-fetch"), 1);
66
-
67
64
  // src/models/jsPdfProcessor.ts
68
65
  var import_jspdf = __toESM(require("jspdf"), 1);
69
66
  var fs = __toESM(require("fs"), 1);
@@ -995,6 +992,7 @@ var JsPdfProcessor = class {
995
992
  this.lastResult = "1";
996
993
  }
997
994
  drawText(input) {
995
+ var _a;
998
996
  const subs = this.logAndParseCommand(".drawText", input);
999
997
  const { first: left, rest: rest1 } = getNextNumber(subs);
1000
998
  const { first: top, rest: rest2 } = getNextNumber(rest1);
@@ -1006,7 +1004,7 @@ var JsPdfProcessor = class {
1006
1004
  this.lastObjectWidth = 0;
1007
1005
  this.lastResult = "1";
1008
1006
  if (lines.length > 1) {
1009
- this.lastError = "Text was truncated to fit within the available width";
1007
+ this.lastError = `Text was truncated to fit within the available width (${(_a = lines[0]) == null ? void 0 : _a.substring(0, 20)}...)`;
1010
1008
  this.lastResult = "0";
1011
1009
  if (lines[0]) {
1012
1010
  if (this._pdfDocument.getTextWidth(lines[0]) < maxWidth) {
@@ -1038,7 +1036,7 @@ var JsPdfProcessor = class {
1038
1036
  return false;
1039
1037
  }
1040
1038
  if (isNaN(top)) {
1041
- this.lastError = `Vertical position '${top}' is not a number`;
1039
+ this.lastError = `Vertical position '${top}' is not a number on page ${this._currentPageNumber}.`;
1042
1040
  this.lastResult = "0";
1043
1041
  return false;
1044
1042
  }
@@ -1350,8 +1348,8 @@ var JsPdfProcessor = class {
1350
1348
  this.lastError = "Y Position resulted in negative value, adjusted to 0";
1351
1349
  }
1352
1350
  if (this.posnY > this._pageHeight) {
1351
+ this.lastError = `Y Position ${this.posnY} exceeded page ${this._currentPageNumber} height, adjusted to page height (${this._pageHeight})`;
1353
1352
  this.posnY = this._pageHeight;
1354
- this.lastError = "Y Position exceeded page height, adjusted to page height";
1355
1353
  }
1356
1354
  }
1357
1355
  incVar(input) {
@@ -2144,7 +2142,7 @@ var JsPdfDynamo = class {
2144
2142
  const subs = processor.substitute(input);
2145
2143
  __privateGet(this, _appLogger).debug(`.includeUri ${subs}`);
2146
2144
  try {
2147
- const response = yield (0, import_node_fetch.default)(subs, {
2145
+ const response = yield fetch(subs, {
2148
2146
  headers: { Accept: "text/plain;q=0.9, text/*;q=0.8, */*;q=0.7" }
2149
2147
  });
2150
2148
  if (!response.ok) {
package/dist/index.js CHANGED
@@ -32,9 +32,6 @@ var __async = (__this, __arguments, generator) => {
32
32
  });
33
33
  };
34
34
 
35
- // src/jsPdfDynamo.ts
36
- import fetch2 from "node-fetch";
37
-
38
35
  // src/models/jsPdfProcessor.ts
39
36
  import jsPDF from "jspdf";
40
37
  import * as fs from "fs";
@@ -966,6 +963,7 @@ var JsPdfProcessor = class {
966
963
  this.lastResult = "1";
967
964
  }
968
965
  drawText(input) {
966
+ var _a;
969
967
  const subs = this.logAndParseCommand(".drawText", input);
970
968
  const { first: left, rest: rest1 } = getNextNumber(subs);
971
969
  const { first: top, rest: rest2 } = getNextNumber(rest1);
@@ -977,7 +975,7 @@ var JsPdfProcessor = class {
977
975
  this.lastObjectWidth = 0;
978
976
  this.lastResult = "1";
979
977
  if (lines.length > 1) {
980
- this.lastError = "Text was truncated to fit within the available width";
978
+ this.lastError = `Text was truncated to fit within the available width (${(_a = lines[0]) == null ? void 0 : _a.substring(0, 20)}...)`;
981
979
  this.lastResult = "0";
982
980
  if (lines[0]) {
983
981
  if (this._pdfDocument.getTextWidth(lines[0]) < maxWidth) {
@@ -1009,7 +1007,7 @@ var JsPdfProcessor = class {
1009
1007
  return false;
1010
1008
  }
1011
1009
  if (isNaN(top)) {
1012
- this.lastError = `Vertical position '${top}' is not a number`;
1010
+ this.lastError = `Vertical position '${top}' is not a number on page ${this._currentPageNumber}.`;
1013
1011
  this.lastResult = "0";
1014
1012
  return false;
1015
1013
  }
@@ -1321,8 +1319,8 @@ var JsPdfProcessor = class {
1321
1319
  this.lastError = "Y Position resulted in negative value, adjusted to 0";
1322
1320
  }
1323
1321
  if (this.posnY > this._pageHeight) {
1322
+ this.lastError = `Y Position ${this.posnY} exceeded page ${this._currentPageNumber} height, adjusted to page height (${this._pageHeight})`;
1324
1323
  this.posnY = this._pageHeight;
1325
- this.lastError = "Y Position exceeded page height, adjusted to page height";
1326
1324
  }
1327
1325
  }
1328
1326
  incVar(input) {
@@ -2115,7 +2113,7 @@ var JsPdfDynamo = class {
2115
2113
  const subs = processor.substitute(input);
2116
2114
  __privateGet(this, _appLogger).debug(`.includeUri ${subs}`);
2117
2115
  try {
2118
- const response = yield fetch2(subs, {
2116
+ const response = yield fetch(subs, {
2119
2117
  headers: { Accept: "text/plain;q=0.9, text/*;q=0.8, */*;q=0.7" }
2120
2118
  });
2121
2119
  if (!response.ok) {
@@ -6,7 +6,7 @@
6
6
  .DrawTextWrapped 0 %_CurrentY% %_PageWidth% *None %text%
7
7
  .incCurrentY %_FONTHEIGHT%
8
8
 
9
- .SetVar text jsPdf-Dynamo can be used with browser or NodeJs JavaScript or TypeScript applications.
9
+ .SetVar text jsPdf-Dynamo can be used with browser or NodeJs applications written in JavaScript or TypeScript.
10
10
  .DrawTextWrapped 0 %_CurrentY% %_PageWidth% *None %text%
11
11
  .incCurrentY %_FONTHEIGHT%
12
12
 
@@ -51,7 +51,7 @@
51
51
  .SetVar text Output is driven by a series of plain text 'commands'. These
52
52
  .SetVar text %text% commands can be provided as a list of strings from multiple sources,
53
53
  .SetVar text %text% including the JavaScript or TypeScript application, or loaded from
54
- .SetVar text %text% 'templates' retrieved from a URL (browser or NodeJs) or from local text
54
+ .SetVar text %text% 'templates' retrieved from a URL (browser only) or from local text
55
55
  .SetVar text %text% files (NodeJs only).
56
56
  .DrawTextWrapped 10 %top% %width% *None %text%
57
57
 
@@ -1,12 +1,9 @@
1
- .SetVar CommandName AddImageFromUrl
1
+ .SetVar CommandName AddImageFromUrl (Browser Only)
2
2
  .Do CommandHeading
3
3
  .SetVar text Reads an image from the given URL and stores it for later output. JsPdfDynamo can use all image types
4
4
  .SetVar text %text% that jsPDF supports, including: BMP, GIF, JPEG, PNG, TIFF and WEBP
5
5
  .DrawTextWrapped 0 %_CurrentY% %_PageWidth% CommandCheckPage %text%
6
6
  .incCurrentY %halfLineGap%
7
- .SetVar text This command is available for both browser and NodeJs applications.
8
- .DrawTextWrapped 0 %_CurrentY% %_PageWidth% CommandCheckPage %text%
9
- .incCurrentY %halfLineGap%
10
7
 
11
8
  .SetVar CommandSubHeading Syntax
12
9
  .Do CommandSubHeading
@@ -1,11 +1,8 @@
1
- .SetVar CommandName Include
1
+ .SetVar CommandName Include (NodeJs Only)
2
2
  .Do CommandHeading
3
- .DrawText 0 %_CurrentY% Include a template into the current document. The template itself may include other templates.
4
- .SetVar CommandLine1 The template must be a text file and located relative to the current directory. The template
5
- .Do CommandLine
6
- .SetVar CommandLine1 may contain individual commands or groups of commands. Any individual commands in the
7
- .Do CommandLine
8
- .SetVar CommandLine1 template are run.
3
+ .SetVar CommandLine1 Load commands from a text file in the file system. The loaded commands may also load other commands.
4
+ .SetVar CommandLine1 %CommandLine1% The text file may contain individual commands or groups of commands.
5
+ .SetVar CommandLine1 %CommandLine1% Commands not within a group will be executed.
9
6
  .Do CommandLine
10
7
 
11
8
  .SetVar CommandSubHeading Syntax
@@ -21,11 +18,9 @@
21
18
 
22
19
  .SetVar CommandSubHeading Other
23
20
  .Do CommandSubHeading
24
- .SetVar CommandLine1 The variable _LastResult is set to '1' if the file is found or '0' if the file could not be found or
25
- .Do CommandLine
26
- .SetVar CommandLine1 opened. Note that the _LastResult of any commands run are not available unless they are
27
- .Do CommandLine
28
- .SetVar CommandLine1 saved within the template file to variables.
21
+ .SetVar CommandLine1 The variable _LastResult is set to '1' if the file is found or '0' if the file could not be found or opened.
22
+ .SetVar CommandLine1 %CommandLine1% opened. Note that the _LastResult of any commands run by the include are not available and
23
+ .SetVar CommandLine1 %CommandLine1% should be saved to variables within the included file if required.
29
24
  .Do CommandLine
30
25
 
31
26
  .SetVar CommandSubHeading Examples
@@ -33,12 +28,18 @@
33
28
  .SetVar CommandLine1 Include the template file StdReportLayout.txt:
34
29
  .Do CommandLine
35
30
  .incCurrentY %halfLineGap%
36
- .SetVar CommandLine1 .Include .\StdReportLayout.txt
31
+ .SetVar CommandLine1 .Include ./StdReportLayout.txt
37
32
  .Do CommandLine2
38
33
  .incCurrentY %_FontHeight%
39
34
  .SetVar CommandLine1 Include the template file specified in the 'ReportType' variable:
40
35
  .Do CommandLine
41
36
  .incCurrentY %halfLineGap%
42
- .SetVar CommandLine1 .Include \tmplates\%%%%ReportType%%%%
37
+ .SetVar CommandLine1 .Include /tmplates/%%%%ReportType%%%%
43
38
  .Do CommandLine2
39
+
40
+ .SetVar CommandSubHeading See Also
41
+ .Do CommandSubHeading
42
+ .SetVar CommandLine1 IncludeUrl
43
+ .Do CommandLine
44
+
44
45
  .incCurrentY %_FontHeight%
@@ -0,0 +1,11 @@
1
+ .SetVar CommandName IncludeUrl (Browser Only)
2
+ .Do CommandHeading
3
+ .SetVar CommandLine1 To be documented.
4
+ .Do CommandLine
5
+
6
+ .SetVar CommandSubHeading See Also
7
+ .Do CommandSubHeading
8
+ .SetVar CommandLine1 Include
9
+ .Do CommandLine
10
+
11
+ .incCurrentY %_FontHeight%
@@ -2,21 +2,3 @@
2
2
  .Do CommandHeading
3
3
  .SetVar CommandLine1 To be documented.
4
4
  .Do CommandLine
5
-
6
- .incCurrentY %_FontHeight%
7
- .SetVar CommandLine1 Set a variable named 'BoldText' and then use this variable to set the emphasis of subsequent
8
- .Do CommandLine
9
- .SetVar CommandLine1 text to be bold:
10
- .Do CommandLine
11
- .incCurrentY %halfLineGap%
12
- .SetVar CommandLine1 .SetVar BoldText 1
13
- .Do CommandLine2
14
- .SetVar CommandLine1 .SetFontStyle %%%%BoldText%%%%
15
- .Do CommandLine2
16
-
17
- .SetVar CommandSubHeading See Also
18
- .Do CommandSubHeading
19
- .SetVar CommandLine1 DrawTextBox, DrawText, SetFontType, SetFontSize, SetTextColour
20
- .Do CommandLine
21
-
22
- .incCurrentY %_FontHeight%
@@ -17,18 +17,22 @@
17
17
  .SetVar CommandLine2 The typographical emphasis to apply:
18
18
  .Do CommandLine2
19
19
  .incCurrentY %halfLineGap%
20
- .SetVar CommandLine2 Normal - Normal text (no typographical emphasis)
20
+ .SetVar CommandLine2 -
21
+ .SetVar CommandLine3 Normal - Normal text (no typographical emphasis)
21
22
  .Do CommandLine2
22
23
 
23
- .SetVar CommandLine2 Bold - Bold text
24
+ .SetVar CommandLine2 -
25
+ .SetVar CommandLine3 Bold - Bold text
24
26
  .SetFontStyle Bold
25
27
  .Do CommandLine2
26
28
 
27
- .SetVar CommandLine2 Italic - Italic text
29
+ .SetVar CommandLine2 -
30
+ .SetVar CommandLine3 Italic - Italic text
28
31
  .SetFontStyle Italic
29
32
  .Do CommandLine2
30
33
 
31
- .SetVar CommandLine2 BoldItalic - Bold and italic text
34
+ .SetVar CommandLine2 -
35
+ .SetVar CommandLine3 BoldItalic - Bold and italic text
32
36
  .SetFontStyle BoldItalic
33
37
  .Do CommandLine2
34
38
 
@@ -36,14 +40,11 @@
36
40
 
37
41
  .SetVar CommandSubHeading Other
38
42
  .Do CommandSubHeading
39
- .SetVar CommandLine1 The font style name is not case sensitive so can be either upper, lower
40
- .Do CommandLine
41
- .SetVar CommandLine1 or mixed case.
43
+ .SetVar CommandLine1 The font style name is not case sensitive so can be either upper, lower or mixed case.
42
44
  .Do CommandLine
43
45
  .incCurrentY %halfLineGap%
44
46
  .SetVar CommandLine1 If a valid font style is provided the variable _LastResult is set to '1' otherwise the current
45
- .Do CommandLine
46
- .SetVar CommandLine1 typographical emphasis is unchanged and _LastResult is set to '0'.
47
+ .SetVar CommandLine1 %CommandLine1% typographical emphasis is unchanged and _LastResult is set to '0'.
47
48
  .Do CommandLine
48
49
 
49
50
  .SetVar CommandSubHeading Examples
@@ -51,5 +52,22 @@
51
52
  .SetVar CommandLine1 Set the emphasis of subsequent text to be italic:
52
53
  .Do CommandLine
53
54
  .incCurrentY %halfLineGap%
54
- .SetVar CommandLine1 .SetFontStyle 2
55
+ .SetVar CommandLine1 .SetFontStyle italic
56
+ .Do CommandLine2
57
+
58
+ .incCurrentY %_FontHeight%
59
+ .SetVar CommandLine1 Set a variable named 'BoldText' and then use this variable to set the emphasis of subsequent
60
+ .SetVar CommandLine1 %CommandLine1% text to be bold:
61
+ .Do CommandLine
62
+ .incCurrentY %halfLineGap%
63
+ .SetVar CommandLine1 .SetVar BoldText bold
55
64
  .Do CommandLine2
65
+ .SetVar CommandLine1 .SetFontStyle %%%%BoldText%%%%
66
+ .Do CommandLine2
67
+
68
+ .SetVar CommandSubHeading See Also
69
+ .Do CommandSubHeading
70
+ .SetVar CommandLine1 DrawTextBox, DrawText, SetFontType, SetFontSize, SetTextColour
71
+ .Do CommandLine
72
+
73
+ .incCurrentY %_FontHeight%
@@ -1,6 +1,6 @@
1
1
  .SetVar CommandName SetLineColour
2
2
  .Do CommandHeading
3
- .DrawText 0 %_CurrentY Set the colour of subsequent lines drawn with the DrawBox and DrawLine commands.
3
+ .DrawText 0 %_CurrentY% Set the colour of subsequent lines drawn with the DrawBox and DrawLine commands.
4
4
 
5
5
  .SetVar CommandSubHeading Syntax
6
6
  .Do CommandSubHeading