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/dist/index.js
CHANGED
|
@@ -46,19 +46,19 @@ var AppLogger = class {
|
|
|
46
46
|
this._logger = console;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
trace(message,
|
|
49
|
+
trace(message, args) {
|
|
50
50
|
this.canLog(0) ? this._logger.trace(message, args) : null;
|
|
51
51
|
}
|
|
52
|
-
debug(message,
|
|
52
|
+
debug(message, args) {
|
|
53
53
|
this.canLog(1) ? this._logger.debug(message, args) : null;
|
|
54
54
|
}
|
|
55
|
-
info(message,
|
|
55
|
+
info(message, args) {
|
|
56
56
|
this.canLog(2) ? this._logger.info(message, args) : null;
|
|
57
57
|
}
|
|
58
|
-
warn(message,
|
|
58
|
+
warn(message, args) {
|
|
59
59
|
this.canLog(3) ? this._logger.warn(message, args) : null;
|
|
60
60
|
}
|
|
61
|
-
error(message,
|
|
61
|
+
error(message, args) {
|
|
62
62
|
this.canLog(4) ? this._logger.error(message, args) : null;
|
|
63
63
|
}
|
|
64
64
|
logLevel(newLevel) {
|
|
@@ -235,6 +235,8 @@ function isValidFontStyle(fontStyle) {
|
|
|
235
235
|
// src/models/jsPdfOptions.ts
|
|
236
236
|
var JsPdfOptions = class {
|
|
237
237
|
constructor(options = {}) {
|
|
238
|
+
this.compress = true;
|
|
239
|
+
this.putOnlyUsedFonts = true;
|
|
238
240
|
var _a, _b, _c;
|
|
239
241
|
this.pageSize = ((_a = options.pageSize) == null ? void 0 : _a.toLocaleLowerCase()) || "a4";
|
|
240
242
|
this.orientation = ((_b = options.orientation) == null ? void 0 : _b.toLocaleLowerCase()) || "portrait";
|
|
@@ -314,15 +316,37 @@ var JsPdfProcessor = class {
|
|
|
314
316
|
this.pageOrientation = optn.orientation;
|
|
315
317
|
this.currentUom = optn.unit;
|
|
316
318
|
this._pdfDocument.setLineHeightFactor(1);
|
|
319
|
+
const now = /* @__PURE__ */ new Date();
|
|
317
320
|
this._variables.set(
|
|
318
321
|
"_TIMEHM",
|
|
319
|
-
|
|
322
|
+
now.toLocaleTimeString(void 0, {
|
|
320
323
|
hour12: false,
|
|
321
324
|
hour: "2-digit",
|
|
322
325
|
minute: "2-digit"
|
|
323
326
|
})
|
|
324
327
|
);
|
|
325
|
-
this._variables.set(
|
|
328
|
+
this._variables.set(
|
|
329
|
+
"_DATEDDMMYYYY",
|
|
330
|
+
now.toLocaleDateString("en-GB", {
|
|
331
|
+
day: "2-digit",
|
|
332
|
+
month: "2-digit",
|
|
333
|
+
year: "numeric"
|
|
334
|
+
})
|
|
335
|
+
);
|
|
336
|
+
this._variables.set(
|
|
337
|
+
"_DATEMMDDYYYY",
|
|
338
|
+
now.toLocaleDateString("en-US", {
|
|
339
|
+
day: "2-digit",
|
|
340
|
+
month: "2-digit",
|
|
341
|
+
year: "numeric"
|
|
342
|
+
})
|
|
343
|
+
);
|
|
344
|
+
this._variables.set("_DATEISO", now.toISOString().substring(0, 10));
|
|
345
|
+
this._variables.set("_IMAGEASPECT", "1");
|
|
346
|
+
this._variables.set("_IMAGEHEIGHT", "0");
|
|
347
|
+
this._variables.set("_IMAGEHEIGHTPX", "0");
|
|
348
|
+
this._variables.set("_IMAGEWIDTH", "0");
|
|
349
|
+
this._variables.set("_IMAGEWIDTHPX", "0");
|
|
326
350
|
this._variables.set("_PAGENO", "1");
|
|
327
351
|
this._variables.set("_PAGES", "1");
|
|
328
352
|
this.posnX = 0;
|
|
@@ -687,8 +711,8 @@ var JsPdfProcessor = class {
|
|
|
687
711
|
this.pageWidth = document.internal.pageSize.width - this._marginLeft - this._marginRight;
|
|
688
712
|
}
|
|
689
713
|
}
|
|
690
|
-
|
|
691
|
-
const subs = this.logAndParseCommand(".
|
|
714
|
+
LoadImageFromFile(input) {
|
|
715
|
+
const subs = this.logAndParseCommand(".LoadImageFromFile", input);
|
|
692
716
|
let fileName = subs;
|
|
693
717
|
if (!fileName) {
|
|
694
718
|
this.lastError = "A file name is required.";
|
|
@@ -709,9 +733,9 @@ var JsPdfProcessor = class {
|
|
|
709
733
|
this.lastResult = "0";
|
|
710
734
|
}
|
|
711
735
|
}
|
|
712
|
-
|
|
736
|
+
LoadImageFromUrl(input) {
|
|
713
737
|
return __async(this, null, function* () {
|
|
714
|
-
const subs = this.logAndParseCommand(".
|
|
738
|
+
const subs = this.logAndParseCommand(".LoadImageFromUrl", input);
|
|
715
739
|
let url = subs;
|
|
716
740
|
if (!url) {
|
|
717
741
|
this.lastError = "A URL is required.";
|
|
@@ -754,6 +778,10 @@ var JsPdfProcessor = class {
|
|
|
754
778
|
this.setFixedDec(this.pixelsToUom(info.height), 3)
|
|
755
779
|
);
|
|
756
780
|
this._variables.set("_IMAGEHEIGHTPX", info.height.toString());
|
|
781
|
+
this._variables.set(
|
|
782
|
+
"_IMAGEASPECT",
|
|
783
|
+
info.height > 0 ? this.setFixedDec(info.width / info.height, 3) : "1"
|
|
784
|
+
);
|
|
757
785
|
}
|
|
758
786
|
getContentType(fileName) {
|
|
759
787
|
const mediaType = fileName.split(".").pop();
|
|
@@ -817,6 +845,8 @@ var JsPdfProcessor = class {
|
|
|
817
845
|
const subs = this.logAndParseCommand(".drawDebugGrid", input);
|
|
818
846
|
const savedLineColour = this.lineColour;
|
|
819
847
|
const savedLineWidth = this.lineWidth;
|
|
848
|
+
const savedX = this.posnX;
|
|
849
|
+
const savedY = this.posnY;
|
|
820
850
|
const mm = 0.1;
|
|
821
851
|
const pts = mmToPoints(mm);
|
|
822
852
|
const lineWidth = this.pointsToUom(pts);
|
|
@@ -873,6 +903,8 @@ var JsPdfProcessor = class {
|
|
|
873
903
|
}
|
|
874
904
|
this.lineColour = savedLineColour;
|
|
875
905
|
this.lineWidth = savedLineWidth;
|
|
906
|
+
this.posnX = savedX;
|
|
907
|
+
this.posnY = savedY;
|
|
876
908
|
}
|
|
877
909
|
drawLine(input) {
|
|
878
910
|
const subs = this.logAndParseCommand(".drawLine", input);
|
|
@@ -912,7 +944,7 @@ var JsPdfProcessor = class {
|
|
|
912
944
|
return;
|
|
913
945
|
}
|
|
914
946
|
if (isNaN(imageNo) || imageNo < 0 || imageNo > this._images.length - 1) {
|
|
915
|
-
this.lastError = this._images.length ?
|
|
947
|
+
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";
|
|
916
948
|
this.lastResult = "0";
|
|
917
949
|
return;
|
|
918
950
|
}
|
|
@@ -963,7 +995,6 @@ var JsPdfProcessor = class {
|
|
|
963
995
|
this.lastResult = "1";
|
|
964
996
|
}
|
|
965
997
|
drawText(input) {
|
|
966
|
-
var _a;
|
|
967
998
|
const subs = this.logAndParseCommand(".drawText", input);
|
|
968
999
|
const { first: left, rest: rest1 } = getNextNumber(subs);
|
|
969
1000
|
const { first: top, rest: rest2 } = getNextNumber(rest1);
|
|
@@ -975,7 +1006,7 @@ var JsPdfProcessor = class {
|
|
|
975
1006
|
this.lastObjectWidth = 0;
|
|
976
1007
|
this.lastResult = "1";
|
|
977
1008
|
if (lines.length > 1) {
|
|
978
|
-
this.lastError = `Text was truncated to fit within the available width (${
|
|
1009
|
+
this.lastError = `Text was truncated to fit within the available width (${rest2.substring(0, 20)}...) on page ${this._currentPageNumber}.`;
|
|
979
1010
|
this.lastResult = "0";
|
|
980
1011
|
if (lines[0]) {
|
|
981
1012
|
if (this._pdfDocument.getTextWidth(lines[0]) < maxWidth) {
|
|
@@ -1281,10 +1312,11 @@ var JsPdfProcessor = class {
|
|
|
1281
1312
|
}
|
|
1282
1313
|
ifNotBlank(jsPdfDynamo, input) {
|
|
1283
1314
|
return __async(this, null, function* () {
|
|
1284
|
-
let { first:
|
|
1315
|
+
let { first: value1, rest } = getNextString(input);
|
|
1285
1316
|
const subs = this.substitute(rest.trim());
|
|
1286
|
-
this._logger.debug(".ifNotBlank " +
|
|
1287
|
-
|
|
1317
|
+
this._logger.debug(".ifNotBlank " + value1 + " " + subs);
|
|
1318
|
+
const variable1 = this.substitute(value1);
|
|
1319
|
+
let value = this._variables.get(variable1.toLocaleUpperCase()) || "";
|
|
1288
1320
|
this.lastResult = "-1";
|
|
1289
1321
|
if (value.trim() !== "") {
|
|
1290
1322
|
yield jsPdfDynamo.processDot(this, rest);
|
|
@@ -1367,6 +1399,51 @@ var JsPdfProcessor = class {
|
|
|
1367
1399
|
"Variable " + varName + " incremented to " + this._variables.get(varName)
|
|
1368
1400
|
);
|
|
1369
1401
|
}
|
|
1402
|
+
divVar(input) {
|
|
1403
|
+
let subs = this.substitute(input.trim());
|
|
1404
|
+
this._logger.debug(".divVar " + subs);
|
|
1405
|
+
let { first: varName, rest } = getNextString(subs.toLocaleUpperCase());
|
|
1406
|
+
if (varName === "") {
|
|
1407
|
+
this.lastResult = "0";
|
|
1408
|
+
this.lastError = "DivVar must reference a variable";
|
|
1409
|
+
return;
|
|
1410
|
+
}
|
|
1411
|
+
if (varName.startsWith("_")) {
|
|
1412
|
+
this.lastResult = "0";
|
|
1413
|
+
this.lastError = "DivVar can not be used to update system maintained variables";
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
let varValue = this._variables.get(varName);
|
|
1417
|
+
if (!varValue) {
|
|
1418
|
+
this.lastResult = "0";
|
|
1419
|
+
this.lastError = "Variable '" + varName + "' is not defined";
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1422
|
+
if (isNaN(Number(varValue))) {
|
|
1423
|
+
this._variables.set(varName, "0");
|
|
1424
|
+
}
|
|
1425
|
+
while (rest.length > 0) {
|
|
1426
|
+
const { first: nextOp, rest: remainder } = getNextNumber(rest, 4);
|
|
1427
|
+
rest = remainder;
|
|
1428
|
+
let varValue2 = this._variables.get(varName);
|
|
1429
|
+
if (!isNaN(Number(nextOp)) && Number(nextOp) === 0) {
|
|
1430
|
+
this.lastResult = "0";
|
|
1431
|
+
this.lastError = "Divide by zero error";
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1434
|
+
if (!isNaN(Number(varValue2)) && !isNaN(Number(nextOp))) {
|
|
1435
|
+
this._variables.set(
|
|
1436
|
+
varName,
|
|
1437
|
+
removeTrailingZeros((Number(varValue2) / Number(nextOp)).toFixed(4))
|
|
1438
|
+
);
|
|
1439
|
+
}
|
|
1440
|
+
varValue2 = this._variables.get(varName);
|
|
1441
|
+
}
|
|
1442
|
+
this.lastResult = "1";
|
|
1443
|
+
this._logger.trace(
|
|
1444
|
+
"Variable " + varName + " incremented to " + this._variables.get(varName)
|
|
1445
|
+
);
|
|
1446
|
+
}
|
|
1370
1447
|
multVar(input) {
|
|
1371
1448
|
let subs = this.substitute(input.trim());
|
|
1372
1449
|
this._logger.debug(".multVar " + subs);
|
|
@@ -1493,9 +1570,14 @@ var JsPdfProcessor = class {
|
|
|
1493
1570
|
}
|
|
1494
1571
|
}
|
|
1495
1572
|
setFillColour(input) {
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1573
|
+
const subs = this.logAndParseCommand(".setFillColour", input);
|
|
1574
|
+
const { first: fillColour } = getNextString(subs);
|
|
1575
|
+
if (fillColour === "") {
|
|
1576
|
+
this.lastResult = "0";
|
|
1577
|
+
this.lastError = "A fill colour must be specified";
|
|
1578
|
+
return;
|
|
1579
|
+
}
|
|
1580
|
+
this.fillColour = fillColour;
|
|
1499
1581
|
this.lastResult = "1";
|
|
1500
1582
|
}
|
|
1501
1583
|
setFontName(input) {
|
|
@@ -1511,14 +1593,25 @@ var JsPdfProcessor = class {
|
|
|
1511
1593
|
}
|
|
1512
1594
|
setFontSize(input) {
|
|
1513
1595
|
const subs = this.logAndParseCommand(".setFontSize", input);
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
this.
|
|
1517
|
-
|
|
1518
|
-
}
|
|
1596
|
+
if (subs === "") {
|
|
1597
|
+
this.lastResult = "0";
|
|
1598
|
+
this.lastError = "A font size must be specified";
|
|
1599
|
+
return;
|
|
1600
|
+
}
|
|
1601
|
+
let { first: sizeAlpha } = getNextNumber(subs);
|
|
1602
|
+
const size = Number(sizeAlpha);
|
|
1603
|
+
if (Number.isNaN(size)) {
|
|
1604
|
+
this.lastResult = "0";
|
|
1605
|
+
this.lastError = `A font size must be a number. '${sizeAlpha}' is not a number.`;
|
|
1606
|
+
return;
|
|
1607
|
+
}
|
|
1608
|
+
if (size <= 0) {
|
|
1519
1609
|
this.lastResult = "0";
|
|
1520
|
-
this.lastError = "
|
|
1610
|
+
this.lastError = "A font size must be greater than 0";
|
|
1611
|
+
return;
|
|
1521
1612
|
}
|
|
1613
|
+
this.fontPointSize = size;
|
|
1614
|
+
this.lastResult = "1";
|
|
1522
1615
|
}
|
|
1523
1616
|
setFontStyle(input) {
|
|
1524
1617
|
const subs = this.logAndParseCommand(".setFontStyle", input);
|
|
@@ -1537,9 +1630,14 @@ var JsPdfProcessor = class {
|
|
|
1537
1630
|
this.lastResult = "1";
|
|
1538
1631
|
}
|
|
1539
1632
|
setLineColour(input) {
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1633
|
+
const subs = this.logAndParseCommand(".setFontStyle", input);
|
|
1634
|
+
const { first: lineColour } = getNextString(subs);
|
|
1635
|
+
if (lineColour === "") {
|
|
1636
|
+
this.lastResult = "0";
|
|
1637
|
+
this.lastError = "A line colour must be specified";
|
|
1638
|
+
return;
|
|
1639
|
+
}
|
|
1640
|
+
this.lineColour = lineColour;
|
|
1543
1641
|
this.lastResult = "1";
|
|
1544
1642
|
}
|
|
1545
1643
|
setLineWidth(input) {
|
|
@@ -1645,7 +1743,13 @@ var JsPdfProcessor = class {
|
|
|
1645
1743
|
}
|
|
1646
1744
|
setTextColour(input) {
|
|
1647
1745
|
const subs = this.logAndParseCommand(".setTextColour", input);
|
|
1648
|
-
|
|
1746
|
+
const { first: textColour } = getNextString(subs);
|
|
1747
|
+
if (textColour === "") {
|
|
1748
|
+
this.lastResult = "0";
|
|
1749
|
+
this.lastError = "A text colour must be specified";
|
|
1750
|
+
return;
|
|
1751
|
+
}
|
|
1752
|
+
this.textColour = textColour;
|
|
1649
1753
|
this.lastResult = "1";
|
|
1650
1754
|
}
|
|
1651
1755
|
copyVar(input) {
|
|
@@ -1815,11 +1919,9 @@ var JsPdfDynamo = class {
|
|
|
1815
1919
|
return null;
|
|
1816
1920
|
}
|
|
1817
1921
|
}
|
|
1818
|
-
toBlobUrl(
|
|
1922
|
+
toBlobUrl() {
|
|
1819
1923
|
try {
|
|
1820
|
-
const result = this._processor.PdfDocument.output("bloburi"
|
|
1821
|
-
filename: fileName
|
|
1822
|
-
});
|
|
1924
|
+
const result = this._processor.PdfDocument.output("bloburi");
|
|
1823
1925
|
return result;
|
|
1824
1926
|
} catch (e) {
|
|
1825
1927
|
__privateGet(this, _appLogger).warn(
|
|
@@ -1850,7 +1952,7 @@ var JsPdfDynamo = class {
|
|
|
1850
1952
|
}
|
|
1851
1953
|
processTemplate(processor, input) {
|
|
1852
1954
|
return __async(this, null, function* () {
|
|
1853
|
-
let
|
|
1955
|
+
let inGroupLoading = false;
|
|
1854
1956
|
let grpName = "";
|
|
1855
1957
|
let currGroup = [];
|
|
1856
1958
|
for (let ix = 0; ix < input.length; ix++) {
|
|
@@ -1859,12 +1961,8 @@ var JsPdfDynamo = class {
|
|
|
1859
1961
|
continue;
|
|
1860
1962
|
}
|
|
1861
1963
|
if (currLine.startsWith("[")) {
|
|
1862
|
-
if (
|
|
1863
|
-
|
|
1864
|
-
__privateGet(this, _appLogger).debug(
|
|
1865
|
-
`Finished loading group ${grpName} (${currLine})
|
|
1866
|
-
`
|
|
1867
|
-
);
|
|
1964
|
+
if (inGroupLoading) {
|
|
1965
|
+
inGroupLoading = false;
|
|
1868
1966
|
} else {
|
|
1869
1967
|
if (currLine.length === 1) continue;
|
|
1870
1968
|
grpName = currLine.substring(1);
|
|
@@ -1873,15 +1971,14 @@ var JsPdfDynamo = class {
|
|
|
1873
1971
|
grpName = grpName.substring(0, iy);
|
|
1874
1972
|
}
|
|
1875
1973
|
grpName = grpName.trim().toLocaleUpperCase();
|
|
1876
|
-
|
|
1877
|
-
__privateGet(this, _appLogger).debug(`Loading group ${grpName}
|
|
1878
|
-
`);
|
|
1974
|
+
inGroupLoading = true;
|
|
1975
|
+
__privateGet(this, _appLogger).debug(`Loading group ${grpName}`);
|
|
1879
1976
|
currGroup = [];
|
|
1880
1977
|
__privateGet(this, _groups)[grpName] = currGroup;
|
|
1881
1978
|
}
|
|
1882
1979
|
continue;
|
|
1883
1980
|
}
|
|
1884
|
-
if (
|
|
1981
|
+
if (inGroupLoading) {
|
|
1885
1982
|
currGroup.push(currLine);
|
|
1886
1983
|
__privateGet(this, _appLogger).trace(` ${currLine}`);
|
|
1887
1984
|
continue;
|
|
@@ -1905,12 +2002,6 @@ var JsPdfDynamo = class {
|
|
|
1905
2002
|
case "AddBookmark".toLowerCase():
|
|
1906
2003
|
processor.addBookmark(parameters);
|
|
1907
2004
|
return;
|
|
1908
|
-
case "AddImageFromFile".toLowerCase():
|
|
1909
|
-
processor.addImageFromFile(parameters);
|
|
1910
|
-
return;
|
|
1911
|
-
case "AddImageFromUrl".toLowerCase():
|
|
1912
|
-
yield processor.addImageFromUrl(parameters);
|
|
1913
|
-
return;
|
|
1914
2005
|
case "AddPage".toLowerCase():
|
|
1915
2006
|
processor.addPage(parameters);
|
|
1916
2007
|
return;
|
|
@@ -1920,6 +2011,9 @@ var JsPdfDynamo = class {
|
|
|
1920
2011
|
case "CopyVar".toLowerCase():
|
|
1921
2012
|
processor.copyVar(parameters);
|
|
1922
2013
|
return;
|
|
2014
|
+
case "DivVar".toLowerCase():
|
|
2015
|
+
processor.divVar(parameters);
|
|
2016
|
+
return;
|
|
1923
2017
|
case "Do".toLowerCase():
|
|
1924
2018
|
yield this.processGroups(processor, parameters);
|
|
1925
2019
|
return;
|
|
@@ -1980,6 +2074,12 @@ var JsPdfDynamo = class {
|
|
|
1980
2074
|
case "IncVar".toLowerCase():
|
|
1981
2075
|
processor.incVar(parameters);
|
|
1982
2076
|
return;
|
|
2077
|
+
case "LoadImageFromFile".toLowerCase():
|
|
2078
|
+
processor.LoadImageFromFile(parameters);
|
|
2079
|
+
return;
|
|
2080
|
+
case "LoadImageFromUrl".toLowerCase():
|
|
2081
|
+
yield processor.LoadImageFromUrl(parameters);
|
|
2082
|
+
return;
|
|
1983
2083
|
case "MultVar".toLowerCase():
|
|
1984
2084
|
processor.multVar(parameters);
|
|
1985
2085
|
return;
|
|
@@ -2056,9 +2156,11 @@ var JsPdfDynamo = class {
|
|
|
2056
2156
|
let { first: group, rest } = getNextString(subs);
|
|
2057
2157
|
subs = rest;
|
|
2058
2158
|
__privateGet(this, _appLogger).debug(`
|
|
2059
|
-
[${group}]`);
|
|
2159
|
+
[${group} - Enter]`);
|
|
2060
2160
|
if (__privateGet(this, _groups)[group]) {
|
|
2061
2161
|
yield this.processTemplate(processor, __privateGet(this, _groups)[group]);
|
|
2162
|
+
__privateGet(this, _appLogger).debug(`[${group} - Exit]
|
|
2163
|
+
`);
|
|
2062
2164
|
} else {
|
|
2063
2165
|
__privateGet(this, _appLogger).warn(`Group ${group} was not found.`);
|
|
2064
2166
|
processor.lastResult = "0";
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
|
|
43
43
|
.SetVar top %_CurrentY%
|
|
44
44
|
.DrawText 5 %top% -
|
|
45
|
-
.SetVar text The initial page size, orientation and
|
|
45
|
+
.SetVar text The initial page size, orientation and unit of measure are set when the
|
|
46
46
|
.SetVar text %text% JsPdfDynamo instance is instantiated.
|
|
47
47
|
.DrawTextWrapped 10 %top% %width% *None %text%
|
|
48
48
|
|
|
@@ -10,30 +10,31 @@
|
|
|
10
10
|
.incCurrentY %halfLineGap%
|
|
11
11
|
.DrawText 0 %_CurrentY% Commands are described in a following chapter.
|
|
12
12
|
|
|
13
|
-
.incCurrentY %
|
|
13
|
+
.incCurrentY %halfLineGap%
|
|
14
14
|
.SetVar CommandLine1 Variables are referenced by enclosing them in percentage symbols. For example, to write some
|
|
15
15
|
.SetVar CommandLine1 %CommandLine1% text at the current position on the page the following DrawText command can be used:
|
|
16
|
-
.Do
|
|
17
|
-
.incCurrentY %
|
|
16
|
+
.Do CommandLine
|
|
17
|
+
.incCurrentY %halfLineGap%
|
|
18
18
|
.SetVar CommandLine1 .DrawText %%%%_CurrentX%%%% %%%%_CurrentY%%%% Hello World!
|
|
19
19
|
.Do CommandLine2
|
|
20
|
-
.incCurrentY %
|
|
20
|
+
.incCurrentY %halfLineGap%
|
|
21
21
|
.SetVar CommandLine1 Variables (and commands) are not case sensitive and the above command could also be given as:
|
|
22
|
-
.Do
|
|
23
|
-
.incCurrentY %
|
|
22
|
+
.Do CommandLine
|
|
23
|
+
.incCurrentY %halfLineGap%
|
|
24
24
|
.SetVar CommandLine1 .drawTEXT %%%%_currentX%%%% %%%%_CURRENTy%%%% Hello World!
|
|
25
25
|
.Do CommandLine2
|
|
26
|
-
.incCurrentY %
|
|
26
|
+
.incCurrentY %halfLineGap%
|
|
27
27
|
|
|
28
28
|
.SetVar CommandLine1 Variables are stored as strings though there is a limited capability to perform arithmetic on
|
|
29
29
|
.SetVar CommandLine1 %CommandLine1% variables. For example, the .IncVar command can be used to add or subtract a number from
|
|
30
30
|
.SetVar CommandLine1 %CommandLine1% a variable.
|
|
31
|
-
.Do
|
|
32
|
-
.incCurrentY %
|
|
31
|
+
.Do CommandLine
|
|
32
|
+
.incCurrentY %halfLineGap%
|
|
33
33
|
|
|
34
|
-
.DrawText 0 %_CurrentY% Variables do not have to be assigned a value before being used.
|
|
34
|
+
.DrawText 0 %_CurrentY% Variables do not have to be assigned a value before being used.
|
|
35
|
+
.incCurrentY %halfLineGap%
|
|
35
36
|
.DrawText 0 %_CurrentY% The value of a variable referenced before being assigned a value is an empty string.
|
|
36
|
-
.incCurrentY %
|
|
37
|
+
.incCurrentY %halfLineGap%
|
|
37
38
|
.SetVar CommandLine1 All variables are global, there is no scoping of variables within a group. A variable
|
|
38
39
|
.SetVar CommandLine1 %CommandLine1% defined within a group is available to commands run after that group.
|
|
39
|
-
.Do
|
|
40
|
+
.Do CommandLine
|
|
@@ -31,6 +31,26 @@
|
|
|
31
31
|
.SetVar CommandLine2 The last page orientation specified: 'portrait' or 'landscape'
|
|
32
32
|
.Do VariableLineWide
|
|
33
33
|
|
|
34
|
+
.incCurrentY %halfLineGap%
|
|
35
|
+
.SetVar CommandLine1 _DateDdMmYyyy
|
|
36
|
+
.SetVar CommandLine2 The current date, formatted as DD/MM/YYYY.
|
|
37
|
+
.Do VariableLineWrapped
|
|
38
|
+
|
|
39
|
+
.incCurrentY %halfLineGap%
|
|
40
|
+
.SetVar CommandLine1 _DateMmDdYyyy
|
|
41
|
+
.SetVar CommandLine2 The current date, formatted as MM/DD/YYYY.
|
|
42
|
+
.Do VariableLineWrapped
|
|
43
|
+
|
|
44
|
+
.incCurrentY %halfLineGap%
|
|
45
|
+
.SetVar CommandLine1 _DateISO
|
|
46
|
+
.SetVar CommandLine2 The current date, formatted as YYYY-MM-DD.
|
|
47
|
+
.Do VariableLineWrapped
|
|
48
|
+
|
|
49
|
+
.incCurrentY %halfLineGap%
|
|
50
|
+
.SetVar CommandLine1 _FillColour
|
|
51
|
+
.SetVar CommandLine2 The colour that will be used when rendering any following filled boxes.
|
|
52
|
+
.Do VariableLineWide
|
|
53
|
+
|
|
34
54
|
.incCurrentY %halfLineGap%
|
|
35
55
|
.SetVar CommandLine1 _FontHeight
|
|
36
56
|
.SetVar CommandLine2 The height of the current font. This can be used to create a space between
|
|
@@ -52,6 +72,11 @@
|
|
|
52
72
|
.SetVar CommandLine2 The current font style. For example, "normal" or "italic".
|
|
53
73
|
.Do VariableLine
|
|
54
74
|
|
|
75
|
+
.incCurrentY %halfLineGap%
|
|
76
|
+
.SetVar CommandLine1 _ImageAspect
|
|
77
|
+
.SetVar CommandLine2 The aspect ratio of the last loaded image, calculated as width divided by height.
|
|
78
|
+
.Do VariableLineWrapped
|
|
79
|
+
|
|
55
80
|
.incCurrentY %halfLineGap%
|
|
56
81
|
.SetVar CommandLine1 _ImageHeight
|
|
57
82
|
.SetVar CommandLine2 The height of the last loaded image.
|
|
@@ -110,6 +135,16 @@
|
|
|
110
135
|
.SetVar CommandLine2 %CommandLine2% will contain the number of the added page.
|
|
111
136
|
.Do VariableLineWrapped
|
|
112
137
|
|
|
138
|
+
.incCurrentY %halfLineGap%
|
|
139
|
+
.SetVar CommandLine1 _LineColour
|
|
140
|
+
.SetVar CommandLine2 The colour that will be used to render any following lines.
|
|
141
|
+
.Do VariableLineWide
|
|
142
|
+
|
|
143
|
+
.incCurrentY %halfLineGap%
|
|
144
|
+
.SetVar CommandLine1 _LineWidth
|
|
145
|
+
.SetVar CommandLine2 The width that any following lines will be drawn.
|
|
146
|
+
.Do VariableLine
|
|
147
|
+
|
|
113
148
|
.incCurrentY %halfLineGap%
|
|
114
149
|
.SetVar CommandLine1 _MarginBottom
|
|
115
150
|
.SetVar CommandLine2 The current margin from the bottom edge of the page.
|
|
@@ -165,5 +200,15 @@
|
|
|
165
200
|
.SetVar CommandLine2 %CommandLine2% from the height of the object plus the current vertical spacing, which can
|
|
166
201
|
.SetVar CommandLine2 %CommandLine2% be set with the SetSpaceVert command.
|
|
167
202
|
.Do VariableLineWrapped
|
|
203
|
+
|
|
204
|
+
.incCurrentY %halfLineGap%
|
|
205
|
+
.SetVar CommandLine1 _TextColour
|
|
206
|
+
.SetVar CommandLine2 The colour that will be used when rendering any following text.
|
|
207
|
+
.Do VariableLineWrapped
|
|
208
|
+
|
|
209
|
+
.incCurrentY %halfLineGap%
|
|
210
|
+
.SetVar CommandLine1 _TimeHhMm
|
|
211
|
+
.SetVar CommandLine2 The current time, formatted as HH:MM.
|
|
212
|
+
.Do VariableLineWrapped
|
|
168
213
|
.incCurrentY %_SPACEVERT%
|
|
169
214
|
.Do SetMargins
|
|
@@ -4,15 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
.SetVar CommandSubHeading Syntax
|
|
6
6
|
.Do CommandSubHeading
|
|
7
|
-
.SetVar CommandLine1 .AddPage
|
|
7
|
+
.SetVar CommandLine1 .AddPage PageSize Orientation
|
|
8
8
|
.Do CommandLine2
|
|
9
9
|
|
|
10
10
|
.SetVar CommandSubHeading Parameters
|
|
11
11
|
.Do CommandSubHeading
|
|
12
12
|
.SetVar CommandLine1 PageSize
|
|
13
|
-
.SetVar CommandLine2 The page
|
|
13
|
+
.SetVar CommandLine2 The size of the page to be added: A3, A4, Letter, etc. Optional and if not supplied, the current page size is used.
|
|
14
14
|
.Do CommandLine2
|
|
15
|
-
.SetVar
|
|
15
|
+
.SetVar CommandLine1 Orientation
|
|
16
|
+
.SetVar CommandLine2 The orientation of the page to be added: 'portrait' or 'landscape'. Optional and if not supplied, the
|
|
17
|
+
.SetVar CommandLine2 %CommandLine2% current orientation is used. The orientation can be abbreviated to the first letter, 'p' or 'l'.
|
|
16
18
|
.Do CommandLine2
|
|
17
19
|
|
|
18
20
|
.SetVar CommandSubHeading Other
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
.SetVar CommandSubHeading Syntax
|
|
8
8
|
.Do CommandSubHeading
|
|
9
|
-
.SetVar CommandLine1 .CopyVar
|
|
9
|
+
.SetVar CommandLine1 .CopyVar CopyTo CopyFrom
|
|
10
10
|
.Do CommandLine2
|
|
11
11
|
|
|
12
12
|
.SetVar CommandSubHeading Parameters
|
|
@@ -47,6 +47,6 @@
|
|
|
47
47
|
|
|
48
48
|
.SetVar CommandSubHeading See Also
|
|
49
49
|
.Do CommandSubHeading
|
|
50
|
-
.SetVar CommandLine1 IncVar, MultVar, SetVar
|
|
50
|
+
.SetVar CommandLine1 DivVar, IncVar, MultVar, SetVar
|
|
51
51
|
.Do CommandLine2
|
|
52
52
|
.incCurrentY %_FontHeight%
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
.SetVar CommandName DivVar
|
|
2
|
+
.Do CommandHeading
|
|
3
|
+
.DrawText 0 %_CurrentY% Divide the value of a variable by one or more factors.
|
|
4
|
+
|
|
5
|
+
.SetVar CommandSubHeading Syntax
|
|
6
|
+
.Do CommandSubHeading
|
|
7
|
+
.SetVar CommandLine1 .DivVar Variable Value Value (etc)
|
|
8
|
+
.Do CommandLine2
|
|
9
|
+
|
|
10
|
+
.SetVar CommandSubHeading Parameters
|
|
11
|
+
.Do CommandSubHeading
|
|
12
|
+
.SetVar CommandLine1 Variable
|
|
13
|
+
.SetVar CommandLine2 The name of the variable to update. This is not usually a substitution variable,
|
|
14
|
+
.SetVar CommandLine2 %CommandLine2% but it can be, or contain substitution variables. The variable must exist.
|
|
15
|
+
.Do CommandLine2
|
|
16
|
+
.SetVar CommandLine1 Value
|
|
17
|
+
.SetVar CommandLine2 One or more values to multiple the variable by. These can be constants or substitution variables.
|
|
18
|
+
.Do CommandLine2
|
|
19
|
+
|
|
20
|
+
.SetVar CommandSubHeading Other
|
|
21
|
+
.Do CommandSubHeading
|
|
22
|
+
.SetVar CommandLine1 Variable _LastResult is set to '1' if a valid variable name is provided, otherwise it is set to '0'.
|
|
23
|
+
.Do CommandLine
|
|
24
|
+
.SetVar CommandLine1 The JsPdfDynamo maintained variables (those whose name starts with an underscore) can not
|
|
25
|
+
.Do CommandLine
|
|
26
|
+
.SetVar CommandLine1 be changed by this command.
|
|
27
|
+
.Do CommandLine
|
|
28
|
+
.incCurrentY %halfLineGap%
|
|
29
|
+
.SetVar CommandLine1 The variable name may itself be, or contain a variable.
|
|
30
|
+
.Do CommandLine
|
|
31
|
+
|
|
32
|
+
.SetVar CommandSubHeading Examples
|
|
33
|
+
.Do CommandSubHeading
|
|
34
|
+
.SetVar CommandLine1 Divide the value of the variable 'Total' by '4':
|
|
35
|
+
.Do CommandLine
|
|
36
|
+
.incCurrentY %halfLineGap%
|
|
37
|
+
.SetVar CommandLine1 .SetVar Total 12
|
|
38
|
+
.Do CommandLine2
|
|
39
|
+
.SetVar CommandLine1 .DivVar Total 4
|
|
40
|
+
.Do CommandLine2
|
|
41
|
+
.incCurrentY %_FontHeight%
|
|
42
|
+
|
|
43
|
+
.SetVar CommandLine1 Decrease the value of 'Weight6' by half from '78.6' to '39.3':
|
|
44
|
+
.Do CommandLine
|
|
45
|
+
.incCurrentY %halfLineGap%
|
|
46
|
+
.SetVar CommandLine1 .SetVar index 6
|
|
47
|
+
.Do CommandLine2
|
|
48
|
+
.SetVar CommandLine1 .SetVar Weight%%%%index%%%% 78.6
|
|
49
|
+
.Do CommandLine2
|
|
50
|
+
.SetVar CommandLine1 .DivVar Weight%%%%index%%%% 2
|
|
51
|
+
.Do CommandLine2
|
|
52
|
+
.incCurrentY %_FontHeight%
|
|
53
|
+
|
|
54
|
+
.SetVar CommandLine1 Multiple values can be used to increase value of 'total' from 100 to 5
|
|
55
|
+
.Do CommandLine
|
|
56
|
+
.incCurrentY %halfLineGap%
|
|
57
|
+
.SetVar CommandLine1 .SetVar Total 10
|
|
58
|
+
.Do CommandLine2
|
|
59
|
+
.SetVar CommandLine1 .DivVar Total 10 2
|
|
60
|
+
.Do CommandLine2
|
|
61
|
+
.incCurrentY %_FontHeight%
|
|
62
|
+
|
|
63
|
+
.SetVar CommandSubHeading See Also
|
|
64
|
+
.Do CommandSubHeading
|
|
65
|
+
.SetVar CommandLine1 CopyVar, IncVar, MultVar, SetVar
|
|
66
|
+
.Do CommandLine2
|
|
67
|
+
.incCurrentY %_FontHeight%
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
.DrawText 0 %_CurrentY% 'Do' (ie process) one or more groups of commands that have already been defined.
|
|
4
4
|
.SetVar CommandSubHeading Syntax
|
|
5
5
|
.Do CommandSubHeading
|
|
6
|
-
.SetVar CommandLine1 .Do
|
|
6
|
+
.SetVar CommandLine1 .Do Group1, Group2...etc
|
|
7
7
|
.Do CommandLine2
|
|
8
8
|
|
|
9
9
|
.SetVar CommandSubHeading Parameters
|