jspdf-dynamo 1.0.4 → 1.0.6
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/README.md +3 -3
- package/dist/index.cjs +154 -52
- package/dist/index.d.cts +16 -13
- package/dist/index.d.ts +16 -13
- package/dist/index.js +154 -52
- package/documentation/1. Introduction/Introduction.txt +1 -1
- package/documentation/3. Variables/Introduction.txt +13 -12
- package/documentation/3. Variables/SystemMaintained.txt +45 -0
- package/documentation/4. Commands/AddBookmark.txt +1 -1
- package/documentation/4. Commands/AddPage.txt +5 -3
- package/documentation/4. Commands/CheckPage.txt +1 -1
- package/documentation/4. Commands/CopyVar.txt +2 -2
- package/documentation/4. Commands/DivVar.txt +67 -0
- package/documentation/4. Commands/Do.txt +1 -1
- package/documentation/4. Commands/DoRepeat.txt +1 -1
- package/documentation/4. Commands/DrawBox.txt +1 -1
- package/documentation/4. Commands/DrawDebugGrid.txt +1 -1
- package/documentation/4. Commands/DrawImage.txt +2 -2
- package/documentation/4. Commands/DrawLine.txt +1 -1
- package/documentation/4. Commands/DrawTextWrapped.txt +1 -1
- package/documentation/4. Commands/ForEachPage.txt +1 -1
- package/documentation/4. Commands/IfBlank.txt +1 -1
- package/documentation/4. Commands/IfEq.txt +53 -0
- package/documentation/4. Commands/IfGt.txt +1 -1
- package/documentation/4. Commands/IfNotBlank.txt +1 -1
- package/documentation/4. Commands/IncCurrentX.txt +1 -1
- package/documentation/4. Commands/IncCurrentY.txt +1 -1
- package/documentation/4. Commands/IncVar.txt +1 -1
- package/documentation/4. Commands/{AddImageFromFile.txt → LoadImageFromFile.txt } +6 -6
- package/documentation/4. Commands/{AddImageFromUrl.txt → LoadImageFromUrl.txt } +6 -6
- package/documentation/4. Commands/MultVar.txt +4 -7
- package/documentation/4. Commands/SetCurrentX.txt +1 -1
- package/documentation/4. Commands/SetCurrentY.txt +1 -1
- package/documentation/4. Commands/SetFillColour.txt +4 -2
- package/documentation/4. Commands/SetFontName.txt +80 -1
- package/documentation/4. Commands/SetFontSize.txt +43 -1
- package/documentation/4. Commands/SetFontStyle.txt +4 -5
- package/documentation/4. Commands/SetLineColour.txt +5 -2
- package/documentation/4. Commands/SetLineWidth.txt +6 -6
- package/documentation/4. Commands/SetMargin.txt +10 -13
- package/documentation/4. Commands/SetTextColour.txt +4 -2
- package/documentation/4. Commands/SetVar.txt +2 -3
- package/documentation/5. Other Definitions/pageSizes.txt +3 -3
- package/documentation/Documentation.pdf +0 -0
- package/documentation/documentation.txt +4 -2
- package/examples/1.Simple/simple.pdf +18 -186
- package/examples/2.Invoice/data.txt +21 -0
- package/examples/2.Invoice/gearz.png +0 -0
- package/examples/2.Invoice/invoice.pdf +0 -0
- package/examples/2.Invoice/invoice.spec.ts +62 -0
- package/examples/2.Invoice/parts.json +324 -0
- package/examples/2.Invoice/template.txt +136 -0
- 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
|
|
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
|
|
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
|
|
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,
|
|
78
|
+
trace(message, args) {
|
|
79
79
|
this.canLog(0) ? this._logger.trace(message, args) : null;
|
|
80
80
|
}
|
|
81
|
-
debug(message,
|
|
81
|
+
debug(message, args) {
|
|
82
82
|
this.canLog(1) ? this._logger.debug(message, args) : null;
|
|
83
83
|
}
|
|
84
|
-
info(message,
|
|
84
|
+
info(message, args) {
|
|
85
85
|
this.canLog(2) ? this._logger.info(message, args) : null;
|
|
86
86
|
}
|
|
87
|
-
warn(message,
|
|
87
|
+
warn(message, args) {
|
|
88
88
|
this.canLog(3) ? this._logger.warn(message, args) : null;
|
|
89
89
|
}
|
|
90
|
-
error(message,
|
|
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,37 @@ 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
|
-
|
|
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(
|
|
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));
|
|
374
|
+
this._variables.set("_IMAGEASPECT", "1");
|
|
375
|
+
this._variables.set("_IMAGEHEIGHT", "0");
|
|
376
|
+
this._variables.set("_IMAGEHEIGHTPX", "0");
|
|
377
|
+
this._variables.set("_IMAGEWIDTH", "0");
|
|
378
|
+
this._variables.set("_IMAGEWIDTHPX", "0");
|
|
355
379
|
this._variables.set("_PAGENO", "1");
|
|
356
380
|
this._variables.set("_PAGES", "1");
|
|
357
381
|
this.posnX = 0;
|
|
@@ -716,8 +740,8 @@ var JsPdfProcessor = class {
|
|
|
716
740
|
this.pageWidth = document.internal.pageSize.width - this._marginLeft - this._marginRight;
|
|
717
741
|
}
|
|
718
742
|
}
|
|
719
|
-
|
|
720
|
-
const subs = this.logAndParseCommand(".
|
|
743
|
+
LoadImageFromFile(input) {
|
|
744
|
+
const subs = this.logAndParseCommand(".LoadImageFromFile", input);
|
|
721
745
|
let fileName = subs;
|
|
722
746
|
if (!fileName) {
|
|
723
747
|
this.lastError = "A file name is required.";
|
|
@@ -738,9 +762,9 @@ var JsPdfProcessor = class {
|
|
|
738
762
|
this.lastResult = "0";
|
|
739
763
|
}
|
|
740
764
|
}
|
|
741
|
-
|
|
765
|
+
LoadImageFromUrl(input) {
|
|
742
766
|
return __async(this, null, function* () {
|
|
743
|
-
const subs = this.logAndParseCommand(".
|
|
767
|
+
const subs = this.logAndParseCommand(".LoadImageFromUrl", input);
|
|
744
768
|
let url = subs;
|
|
745
769
|
if (!url) {
|
|
746
770
|
this.lastError = "A URL is required.";
|
|
@@ -783,6 +807,10 @@ var JsPdfProcessor = class {
|
|
|
783
807
|
this.setFixedDec(this.pixelsToUom(info.height), 3)
|
|
784
808
|
);
|
|
785
809
|
this._variables.set("_IMAGEHEIGHTPX", info.height.toString());
|
|
810
|
+
this._variables.set(
|
|
811
|
+
"_IMAGEASPECT",
|
|
812
|
+
info.height > 0 ? this.setFixedDec(info.width / info.height, 3) : "1"
|
|
813
|
+
);
|
|
786
814
|
}
|
|
787
815
|
getContentType(fileName) {
|
|
788
816
|
const mediaType = fileName.split(".").pop();
|
|
@@ -846,6 +874,8 @@ var JsPdfProcessor = class {
|
|
|
846
874
|
const subs = this.logAndParseCommand(".drawDebugGrid", input);
|
|
847
875
|
const savedLineColour = this.lineColour;
|
|
848
876
|
const savedLineWidth = this.lineWidth;
|
|
877
|
+
const savedX = this.posnX;
|
|
878
|
+
const savedY = this.posnY;
|
|
849
879
|
const mm = 0.1;
|
|
850
880
|
const pts = mmToPoints(mm);
|
|
851
881
|
const lineWidth = this.pointsToUom(pts);
|
|
@@ -902,6 +932,8 @@ var JsPdfProcessor = class {
|
|
|
902
932
|
}
|
|
903
933
|
this.lineColour = savedLineColour;
|
|
904
934
|
this.lineWidth = savedLineWidth;
|
|
935
|
+
this.posnX = savedX;
|
|
936
|
+
this.posnY = savedY;
|
|
905
937
|
}
|
|
906
938
|
drawLine(input) {
|
|
907
939
|
const subs = this.logAndParseCommand(".drawLine", input);
|
|
@@ -941,7 +973,7 @@ var JsPdfProcessor = class {
|
|
|
941
973
|
return;
|
|
942
974
|
}
|
|
943
975
|
if (isNaN(imageNo) || imageNo < 0 || imageNo > this._images.length - 1) {
|
|
944
|
-
this.lastError = this._images.length ?
|
|
976
|
+
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";
|
|
945
977
|
this.lastResult = "0";
|
|
946
978
|
return;
|
|
947
979
|
}
|
|
@@ -992,7 +1024,6 @@ var JsPdfProcessor = class {
|
|
|
992
1024
|
this.lastResult = "1";
|
|
993
1025
|
}
|
|
994
1026
|
drawText(input) {
|
|
995
|
-
var _a;
|
|
996
1027
|
const subs = this.logAndParseCommand(".drawText", input);
|
|
997
1028
|
const { first: left, rest: rest1 } = getNextNumber(subs);
|
|
998
1029
|
const { first: top, rest: rest2 } = getNextNumber(rest1);
|
|
@@ -1004,7 +1035,7 @@ var JsPdfProcessor = class {
|
|
|
1004
1035
|
this.lastObjectWidth = 0;
|
|
1005
1036
|
this.lastResult = "1";
|
|
1006
1037
|
if (lines.length > 1) {
|
|
1007
|
-
this.lastError = `Text was truncated to fit within the available width (${
|
|
1038
|
+
this.lastError = `Text was truncated to fit within the available width (${rest2.substring(0, 20)}...) on page ${this._currentPageNumber}.`;
|
|
1008
1039
|
this.lastResult = "0";
|
|
1009
1040
|
if (lines[0]) {
|
|
1010
1041
|
if (this._pdfDocument.getTextWidth(lines[0]) < maxWidth) {
|
|
@@ -1310,10 +1341,11 @@ var JsPdfProcessor = class {
|
|
|
1310
1341
|
}
|
|
1311
1342
|
ifNotBlank(jsPdfDynamo, input) {
|
|
1312
1343
|
return __async(this, null, function* () {
|
|
1313
|
-
let { first:
|
|
1344
|
+
let { first: value1, rest } = getNextString(input);
|
|
1314
1345
|
const subs = this.substitute(rest.trim());
|
|
1315
|
-
this._logger.debug(".ifNotBlank " +
|
|
1316
|
-
|
|
1346
|
+
this._logger.debug(".ifNotBlank " + value1 + " " + subs);
|
|
1347
|
+
const variable1 = this.substitute(value1);
|
|
1348
|
+
let value = this._variables.get(variable1.toLocaleUpperCase()) || "";
|
|
1317
1349
|
this.lastResult = "-1";
|
|
1318
1350
|
if (value.trim() !== "") {
|
|
1319
1351
|
yield jsPdfDynamo.processDot(this, rest);
|
|
@@ -1396,6 +1428,51 @@ var JsPdfProcessor = class {
|
|
|
1396
1428
|
"Variable " + varName + " incremented to " + this._variables.get(varName)
|
|
1397
1429
|
);
|
|
1398
1430
|
}
|
|
1431
|
+
divVar(input) {
|
|
1432
|
+
let subs = this.substitute(input.trim());
|
|
1433
|
+
this._logger.debug(".divVar " + subs);
|
|
1434
|
+
let { first: varName, rest } = getNextString(subs.toLocaleUpperCase());
|
|
1435
|
+
if (varName === "") {
|
|
1436
|
+
this.lastResult = "0";
|
|
1437
|
+
this.lastError = "DivVar must reference a variable";
|
|
1438
|
+
return;
|
|
1439
|
+
}
|
|
1440
|
+
if (varName.startsWith("_")) {
|
|
1441
|
+
this.lastResult = "0";
|
|
1442
|
+
this.lastError = "DivVar can not be used to update system maintained variables";
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
let varValue = this._variables.get(varName);
|
|
1446
|
+
if (!varValue) {
|
|
1447
|
+
this.lastResult = "0";
|
|
1448
|
+
this.lastError = "Variable '" + varName + "' is not defined";
|
|
1449
|
+
return;
|
|
1450
|
+
}
|
|
1451
|
+
if (isNaN(Number(varValue))) {
|
|
1452
|
+
this._variables.set(varName, "0");
|
|
1453
|
+
}
|
|
1454
|
+
while (rest.length > 0) {
|
|
1455
|
+
const { first: nextOp, rest: remainder } = getNextNumber(rest, 4);
|
|
1456
|
+
rest = remainder;
|
|
1457
|
+
let varValue2 = this._variables.get(varName);
|
|
1458
|
+
if (!isNaN(Number(nextOp)) && Number(nextOp) === 0) {
|
|
1459
|
+
this.lastResult = "0";
|
|
1460
|
+
this.lastError = "Divide by zero error";
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1463
|
+
if (!isNaN(Number(varValue2)) && !isNaN(Number(nextOp))) {
|
|
1464
|
+
this._variables.set(
|
|
1465
|
+
varName,
|
|
1466
|
+
removeTrailingZeros((Number(varValue2) / Number(nextOp)).toFixed(4))
|
|
1467
|
+
);
|
|
1468
|
+
}
|
|
1469
|
+
varValue2 = this._variables.get(varName);
|
|
1470
|
+
}
|
|
1471
|
+
this.lastResult = "1";
|
|
1472
|
+
this._logger.trace(
|
|
1473
|
+
"Variable " + varName + " incremented to " + this._variables.get(varName)
|
|
1474
|
+
);
|
|
1475
|
+
}
|
|
1399
1476
|
multVar(input) {
|
|
1400
1477
|
let subs = this.substitute(input.trim());
|
|
1401
1478
|
this._logger.debug(".multVar " + subs);
|
|
@@ -1522,9 +1599,14 @@ var JsPdfProcessor = class {
|
|
|
1522
1599
|
}
|
|
1523
1600
|
}
|
|
1524
1601
|
setFillColour(input) {
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1602
|
+
const subs = this.logAndParseCommand(".setFillColour", input);
|
|
1603
|
+
const { first: fillColour } = getNextString(subs);
|
|
1604
|
+
if (fillColour === "") {
|
|
1605
|
+
this.lastResult = "0";
|
|
1606
|
+
this.lastError = "A fill colour must be specified";
|
|
1607
|
+
return;
|
|
1608
|
+
}
|
|
1609
|
+
this.fillColour = fillColour;
|
|
1528
1610
|
this.lastResult = "1";
|
|
1529
1611
|
}
|
|
1530
1612
|
setFontName(input) {
|
|
@@ -1540,14 +1622,25 @@ var JsPdfProcessor = class {
|
|
|
1540
1622
|
}
|
|
1541
1623
|
setFontSize(input) {
|
|
1542
1624
|
const subs = this.logAndParseCommand(".setFontSize", input);
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
this.
|
|
1546
|
-
|
|
1547
|
-
}
|
|
1625
|
+
if (subs === "") {
|
|
1626
|
+
this.lastResult = "0";
|
|
1627
|
+
this.lastError = "A font size must be specified";
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
let { first: sizeAlpha } = getNextNumber(subs);
|
|
1631
|
+
const size = Number(sizeAlpha);
|
|
1632
|
+
if (Number.isNaN(size)) {
|
|
1633
|
+
this.lastResult = "0";
|
|
1634
|
+
this.lastError = `A font size must be a number. '${sizeAlpha}' is not a number.`;
|
|
1635
|
+
return;
|
|
1636
|
+
}
|
|
1637
|
+
if (size <= 0) {
|
|
1548
1638
|
this.lastResult = "0";
|
|
1549
|
-
this.lastError = "
|
|
1639
|
+
this.lastError = "A font size must be greater than 0";
|
|
1640
|
+
return;
|
|
1550
1641
|
}
|
|
1642
|
+
this.fontPointSize = size;
|
|
1643
|
+
this.lastResult = "1";
|
|
1551
1644
|
}
|
|
1552
1645
|
setFontStyle(input) {
|
|
1553
1646
|
const subs = this.logAndParseCommand(".setFontStyle", input);
|
|
@@ -1566,9 +1659,14 @@ var JsPdfProcessor = class {
|
|
|
1566
1659
|
this.lastResult = "1";
|
|
1567
1660
|
}
|
|
1568
1661
|
setLineColour(input) {
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1662
|
+
const subs = this.logAndParseCommand(".setFontStyle", input);
|
|
1663
|
+
const { first: lineColour } = getNextString(subs);
|
|
1664
|
+
if (lineColour === "") {
|
|
1665
|
+
this.lastResult = "0";
|
|
1666
|
+
this.lastError = "A line colour must be specified";
|
|
1667
|
+
return;
|
|
1668
|
+
}
|
|
1669
|
+
this.lineColour = lineColour;
|
|
1572
1670
|
this.lastResult = "1";
|
|
1573
1671
|
}
|
|
1574
1672
|
setLineWidth(input) {
|
|
@@ -1674,7 +1772,13 @@ var JsPdfProcessor = class {
|
|
|
1674
1772
|
}
|
|
1675
1773
|
setTextColour(input) {
|
|
1676
1774
|
const subs = this.logAndParseCommand(".setTextColour", input);
|
|
1677
|
-
|
|
1775
|
+
const { first: textColour } = getNextString(subs);
|
|
1776
|
+
if (textColour === "") {
|
|
1777
|
+
this.lastResult = "0";
|
|
1778
|
+
this.lastError = "A text colour must be specified";
|
|
1779
|
+
return;
|
|
1780
|
+
}
|
|
1781
|
+
this.textColour = textColour;
|
|
1678
1782
|
this.lastResult = "1";
|
|
1679
1783
|
}
|
|
1680
1784
|
copyVar(input) {
|
|
@@ -1844,11 +1948,9 @@ var JsPdfDynamo = class {
|
|
|
1844
1948
|
return null;
|
|
1845
1949
|
}
|
|
1846
1950
|
}
|
|
1847
|
-
toBlobUrl(
|
|
1951
|
+
toBlobUrl() {
|
|
1848
1952
|
try {
|
|
1849
|
-
const result = this._processor.PdfDocument.output("bloburi"
|
|
1850
|
-
filename: fileName
|
|
1851
|
-
});
|
|
1953
|
+
const result = this._processor.PdfDocument.output("bloburi");
|
|
1852
1954
|
return result;
|
|
1853
1955
|
} catch (e) {
|
|
1854
1956
|
__privateGet(this, _appLogger).warn(
|
|
@@ -1879,7 +1981,7 @@ var JsPdfDynamo = class {
|
|
|
1879
1981
|
}
|
|
1880
1982
|
processTemplate(processor, input) {
|
|
1881
1983
|
return __async(this, null, function* () {
|
|
1882
|
-
let
|
|
1984
|
+
let inGroupLoading = false;
|
|
1883
1985
|
let grpName = "";
|
|
1884
1986
|
let currGroup = [];
|
|
1885
1987
|
for (let ix = 0; ix < input.length; ix++) {
|
|
@@ -1888,12 +1990,8 @@ var JsPdfDynamo = class {
|
|
|
1888
1990
|
continue;
|
|
1889
1991
|
}
|
|
1890
1992
|
if (currLine.startsWith("[")) {
|
|
1891
|
-
if (
|
|
1892
|
-
|
|
1893
|
-
__privateGet(this, _appLogger).debug(
|
|
1894
|
-
`Finished loading group ${grpName} (${currLine})
|
|
1895
|
-
`
|
|
1896
|
-
);
|
|
1993
|
+
if (inGroupLoading) {
|
|
1994
|
+
inGroupLoading = false;
|
|
1897
1995
|
} else {
|
|
1898
1996
|
if (currLine.length === 1) continue;
|
|
1899
1997
|
grpName = currLine.substring(1);
|
|
@@ -1902,15 +2000,14 @@ var JsPdfDynamo = class {
|
|
|
1902
2000
|
grpName = grpName.substring(0, iy);
|
|
1903
2001
|
}
|
|
1904
2002
|
grpName = grpName.trim().toLocaleUpperCase();
|
|
1905
|
-
|
|
1906
|
-
__privateGet(this, _appLogger).debug(`Loading group ${grpName}
|
|
1907
|
-
`);
|
|
2003
|
+
inGroupLoading = true;
|
|
2004
|
+
__privateGet(this, _appLogger).debug(`Loading group ${grpName}`);
|
|
1908
2005
|
currGroup = [];
|
|
1909
2006
|
__privateGet(this, _groups)[grpName] = currGroup;
|
|
1910
2007
|
}
|
|
1911
2008
|
continue;
|
|
1912
2009
|
}
|
|
1913
|
-
if (
|
|
2010
|
+
if (inGroupLoading) {
|
|
1914
2011
|
currGroup.push(currLine);
|
|
1915
2012
|
__privateGet(this, _appLogger).trace(` ${currLine}`);
|
|
1916
2013
|
continue;
|
|
@@ -1934,12 +2031,6 @@ var JsPdfDynamo = class {
|
|
|
1934
2031
|
case "AddBookmark".toLowerCase():
|
|
1935
2032
|
processor.addBookmark(parameters);
|
|
1936
2033
|
return;
|
|
1937
|
-
case "AddImageFromFile".toLowerCase():
|
|
1938
|
-
processor.addImageFromFile(parameters);
|
|
1939
|
-
return;
|
|
1940
|
-
case "AddImageFromUrl".toLowerCase():
|
|
1941
|
-
yield processor.addImageFromUrl(parameters);
|
|
1942
|
-
return;
|
|
1943
2034
|
case "AddPage".toLowerCase():
|
|
1944
2035
|
processor.addPage(parameters);
|
|
1945
2036
|
return;
|
|
@@ -1949,6 +2040,9 @@ var JsPdfDynamo = class {
|
|
|
1949
2040
|
case "CopyVar".toLowerCase():
|
|
1950
2041
|
processor.copyVar(parameters);
|
|
1951
2042
|
return;
|
|
2043
|
+
case "DivVar".toLowerCase():
|
|
2044
|
+
processor.divVar(parameters);
|
|
2045
|
+
return;
|
|
1952
2046
|
case "Do".toLowerCase():
|
|
1953
2047
|
yield this.processGroups(processor, parameters);
|
|
1954
2048
|
return;
|
|
@@ -2009,6 +2103,12 @@ var JsPdfDynamo = class {
|
|
|
2009
2103
|
case "IncVar".toLowerCase():
|
|
2010
2104
|
processor.incVar(parameters);
|
|
2011
2105
|
return;
|
|
2106
|
+
case "LoadImageFromFile".toLowerCase():
|
|
2107
|
+
processor.LoadImageFromFile(parameters);
|
|
2108
|
+
return;
|
|
2109
|
+
case "LoadImageFromUrl".toLowerCase():
|
|
2110
|
+
yield processor.LoadImageFromUrl(parameters);
|
|
2111
|
+
return;
|
|
2012
2112
|
case "MultVar".toLowerCase():
|
|
2013
2113
|
processor.multVar(parameters);
|
|
2014
2114
|
return;
|
|
@@ -2085,9 +2185,11 @@ var JsPdfDynamo = class {
|
|
|
2085
2185
|
let { first: group, rest } = getNextString(subs);
|
|
2086
2186
|
subs = rest;
|
|
2087
2187
|
__privateGet(this, _appLogger).debug(`
|
|
2088
|
-
[${group}]`);
|
|
2188
|
+
[${group} - Enter]`);
|
|
2089
2189
|
if (__privateGet(this, _groups)[group]) {
|
|
2090
2190
|
yield this.processTemplate(processor, __privateGet(this, _groups)[group]);
|
|
2191
|
+
__privateGet(this, _appLogger).debug(`[${group} - Exit]
|
|
2192
|
+
`);
|
|
2091
2193
|
} else {
|
|
2092
2194
|
__privateGet(this, _appLogger).warn(`Group ${group} was not found.`);
|
|
2093
2195
|
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,
|
|
5
|
-
error: (message: string,
|
|
6
|
-
info: (message: string,
|
|
7
|
-
trace: (message: string,
|
|
8
|
-
warn: (message: string,
|
|
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,
|
|
15
|
-
debug(message: string,
|
|
16
|
-
info(message: string,
|
|
17
|
-
warn(message: string,
|
|
18
|
-
error(message: string,
|
|
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
|
}
|
|
@@ -307,8 +309,8 @@ declare class JsPdfProcessor {
|
|
|
307
309
|
addBookmark(input: string): void;
|
|
308
310
|
addPage(input?: string): void;
|
|
309
311
|
private calcPageDimensions;
|
|
310
|
-
|
|
311
|
-
|
|
312
|
+
LoadImageFromFile(input: string): void;
|
|
313
|
+
LoadImageFromUrl(input: string): Promise<void>;
|
|
312
314
|
private saveImage;
|
|
313
315
|
private getContentType;
|
|
314
316
|
checkPage(jsPdfDynamo: JsPdfDynamo, input: string): Promise<void>;
|
|
@@ -329,6 +331,7 @@ declare class JsPdfProcessor {
|
|
|
329
331
|
incCurrentX(input: string): void;
|
|
330
332
|
incCurrentY(input: string): void;
|
|
331
333
|
incVar(input: string): void;
|
|
334
|
+
divVar(input: string): void;
|
|
332
335
|
multVar(input: string): void;
|
|
333
336
|
savePdf(input: string): void;
|
|
334
337
|
selectPage(input: string): void;
|
|
@@ -365,7 +368,7 @@ declare class JsPdfDynamo {
|
|
|
365
368
|
_processor: JsPdfProcessor;
|
|
366
369
|
constructor(options?: Partial<IJsPdfOptions>, logger?: ILogger | null);
|
|
367
370
|
toBlob(): Blob | null;
|
|
368
|
-
toBlobUrl(
|
|
371
|
+
toBlobUrl(): string | null;
|
|
369
372
|
getVariable(variableName: string): string | null;
|
|
370
373
|
private prepareNewPdf;
|
|
371
374
|
prepareWrappedString(input: string): string;
|
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,
|
|
5
|
-
error: (message: string,
|
|
6
|
-
info: (message: string,
|
|
7
|
-
trace: (message: string,
|
|
8
|
-
warn: (message: string,
|
|
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,
|
|
15
|
-
debug(message: string,
|
|
16
|
-
info(message: string,
|
|
17
|
-
warn(message: string,
|
|
18
|
-
error(message: string,
|
|
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
|
}
|
|
@@ -307,8 +309,8 @@ declare class JsPdfProcessor {
|
|
|
307
309
|
addBookmark(input: string): void;
|
|
308
310
|
addPage(input?: string): void;
|
|
309
311
|
private calcPageDimensions;
|
|
310
|
-
|
|
311
|
-
|
|
312
|
+
LoadImageFromFile(input: string): void;
|
|
313
|
+
LoadImageFromUrl(input: string): Promise<void>;
|
|
312
314
|
private saveImage;
|
|
313
315
|
private getContentType;
|
|
314
316
|
checkPage(jsPdfDynamo: JsPdfDynamo, input: string): Promise<void>;
|
|
@@ -329,6 +331,7 @@ declare class JsPdfProcessor {
|
|
|
329
331
|
incCurrentX(input: string): void;
|
|
330
332
|
incCurrentY(input: string): void;
|
|
331
333
|
incVar(input: string): void;
|
|
334
|
+
divVar(input: string): void;
|
|
332
335
|
multVar(input: string): void;
|
|
333
336
|
savePdf(input: string): void;
|
|
334
337
|
selectPage(input: string): void;
|
|
@@ -365,7 +368,7 @@ declare class JsPdfDynamo {
|
|
|
365
368
|
_processor: JsPdfProcessor;
|
|
366
369
|
constructor(options?: Partial<IJsPdfOptions>, logger?: ILogger | null);
|
|
367
370
|
toBlob(): Blob | null;
|
|
368
|
-
toBlobUrl(
|
|
371
|
+
toBlobUrl(): string | null;
|
|
369
372
|
getVariable(variableName: string): string | null;
|
|
370
373
|
private prepareNewPdf;
|
|
371
374
|
prepareWrappedString(input: string): string;
|