jspdf-dynamo 1.0.0 → 1.0.4
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 +26 -23
- package/dist/index.d.cts +16 -5
- package/dist/index.d.ts +16 -5
- package/dist/index.js +26 -23
- package/documentation/1. Introduction/Introduction.txt +2 -2
- package/documentation/3. Variables/Introduction.txt +15 -12
- package/documentation/3. Variables/SystemMaintained.txt +44 -65
- package/documentation/4. Commands/AddBookmark.txt +3 -3
- package/documentation/4. Commands/AddImageFromFile.txt +3 -3
- package/documentation/4. Commands/AddImageFromUrl.txt +4 -7
- package/documentation/4. Commands/AddPage.txt +1 -1
- package/documentation/4. Commands/CheckPage.txt +2 -2
- package/documentation/4. Commands/Commands.txt +7 -0
- package/documentation/4. Commands/CopyVar.txt +1 -1
- package/documentation/4. Commands/Do.txt +2 -2
- package/documentation/4. Commands/DoRepeat.txt +2 -2
- package/documentation/4. Commands/DrawBox.txt +2 -2
- package/documentation/4. Commands/DrawDebugGrid.txt +2 -2
- package/documentation/4. Commands/DrawImage.txt +2 -2
- package/documentation/4. Commands/DrawLine.txt +2 -2
- package/documentation/4. Commands/DrawTextBox.txt +1 -1
- package/documentation/4. Commands/DrawTextWrapped.txt +40 -17
- package/documentation/4. Commands/ForEachPage.txt +3 -3
- package/documentation/4. Commands/GetEnvVar.txt +2 -2
- package/documentation/4. Commands/IfNotBlank.txt +3 -3
- package/documentation/4. Commands/IncVar.txt +7 -7
- package/documentation/4. Commands/Include.txt +16 -15
- package/documentation/4. Commands/IncludeUrl.txt +53 -0
- package/documentation/4. Commands/MultVar.txt +7 -7
- package/documentation/4. Commands/SavePdf.txt +6 -0
- package/documentation/4. Commands/SelectPage.txt +6 -0
- package/documentation/4. Commands/SetCurrentX.txt +4 -4
- package/documentation/4. Commands/SetCurrentY.txt +2 -2
- package/documentation/4. Commands/SetDocumentInfo.txt +3 -3
- package/documentation/4. Commands/SetFillColour.txt +8 -25
- package/documentation/4. Commands/SetFontName.txt +3 -1
- package/documentation/4. Commands/SetFontSize.txt +0 -16
- package/documentation/4. Commands/SetFontStyle.txt +28 -10
- package/documentation/4. Commands/SetLineColour.txt +9 -27
- package/documentation/4. Commands/SetLineWidth.txt +1 -1
- package/documentation/4. Commands/SetLogLevel.txt +6 -0
- package/documentation/4. Commands/SetMargin.txt +1 -1
- package/documentation/4. Commands/SetTextColour.txt +43 -0
- package/documentation/4. Commands/SetVar.txt +7 -7
- package/documentation/4. Commands/WriteLog.txt +56 -0
- package/documentation/Documentation.pdf +2093 -1853
- package/documentation/documentation.txt +19 -10
- package/examples/1.Simple/simple.pdf +2 -2
- package/package.json +10 -4
- package/documentation/4. Commands/SetPageOrientation.txt +0 -42
- package/documentation/6. Other/PossibleEnhancements.txt +0 -63
- package/documentation/6. Other/To Be Documented.txt +0 -50
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);
|
|
@@ -121,9 +118,6 @@ var AppLogger = class {
|
|
|
121
118
|
this._logLevel = newLevel;
|
|
122
119
|
}
|
|
123
120
|
}
|
|
124
|
-
if (this._logger.logLevel) {
|
|
125
|
-
this._logger.logLevel(this._logLevel);
|
|
126
|
-
}
|
|
127
121
|
}
|
|
128
122
|
canLog(level) {
|
|
129
123
|
return level >= this._logLevel;
|
|
@@ -360,8 +354,11 @@ var JsPdfProcessor = class {
|
|
|
360
354
|
this._variables.set("_DATEDMY", (/* @__PURE__ */ new Date()).toLocaleDateString("en-GB"));
|
|
361
355
|
this._variables.set("_PAGENO", "1");
|
|
362
356
|
this._variables.set("_PAGES", "1");
|
|
357
|
+
this.posnX = 0;
|
|
358
|
+
this.posnY = 0;
|
|
363
359
|
this.spaceHoz = 0;
|
|
364
360
|
this.spaceVert = 0;
|
|
361
|
+
this.currentPageNumber = 1;
|
|
365
362
|
this.lineWidth = this.pointsToUom(mmToPoints(0.2));
|
|
366
363
|
this.lineColour = "black";
|
|
367
364
|
this.fontPointSize = 12;
|
|
@@ -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 =
|
|
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
|
}
|
|
@@ -1195,10 +1193,16 @@ var JsPdfProcessor = class {
|
|
|
1195
1193
|
return;
|
|
1196
1194
|
}
|
|
1197
1195
|
let lastObjectHeight = 0;
|
|
1198
|
-
text = text.replace(
|
|
1196
|
+
text = text.replace(/\\[nN]/g, " \n") + " ";
|
|
1197
|
+
const splitText = text.split("\n");
|
|
1198
|
+
const lines = [];
|
|
1199
|
+
for (let line of splitText) {
|
|
1200
|
+
lines.push(...this._pdfDocument.splitTextToSize(line, maxWidth));
|
|
1201
|
+
}
|
|
1202
|
+
if (lines.length > splitText.length) {
|
|
1203
|
+
this._logger.trace(`Text was wrapped into ${lines.length} lines`, lines);
|
|
1204
|
+
}
|
|
1199
1205
|
this.posnY = top;
|
|
1200
|
-
const lines = this._pdfDocument.splitTextToSize(text, maxWidth) || [];
|
|
1201
|
-
this._logger.trace(`Text was wrapped into ${lines.length} lines`, lines);
|
|
1202
1206
|
while (lines.length > 0) {
|
|
1203
1207
|
if (!cmdGroup.startsWith("*")) {
|
|
1204
1208
|
yield jsPdfDynamo.processGroups(this, cmdGroup, false);
|
|
@@ -1350,8 +1354,8 @@ var JsPdfProcessor = class {
|
|
|
1350
1354
|
this.lastError = "Y Position resulted in negative value, adjusted to 0";
|
|
1351
1355
|
}
|
|
1352
1356
|
if (this.posnY > this._pageHeight) {
|
|
1357
|
+
this.lastError = `Y Position ${this.posnY} exceeded page ${this._currentPageNumber} height, adjusted to page height (${this._pageHeight})`;
|
|
1353
1358
|
this.posnY = this._pageHeight;
|
|
1354
|
-
this.lastError = "Y Position exceeded page height, adjusted to page height";
|
|
1355
1359
|
}
|
|
1356
1360
|
}
|
|
1357
1361
|
incVar(input) {
|
|
@@ -1840,12 +1844,11 @@ var JsPdfDynamo = class {
|
|
|
1840
1844
|
return null;
|
|
1841
1845
|
}
|
|
1842
1846
|
}
|
|
1843
|
-
toBlobUrl() {
|
|
1847
|
+
toBlobUrl(fileName) {
|
|
1844
1848
|
try {
|
|
1845
|
-
const result = this._processor.PdfDocument.output(
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
);
|
|
1849
|
+
const result = this._processor.PdfDocument.output("bloburi", {
|
|
1850
|
+
filename: fileName
|
|
1851
|
+
});
|
|
1849
1852
|
return result;
|
|
1850
1853
|
} catch (e) {
|
|
1851
1854
|
__privateGet(this, _appLogger).warn(
|
|
@@ -1854,7 +1857,7 @@ var JsPdfDynamo = class {
|
|
|
1854
1857
|
return null;
|
|
1855
1858
|
}
|
|
1856
1859
|
}
|
|
1857
|
-
|
|
1860
|
+
getVariable(variableName) {
|
|
1858
1861
|
var _a;
|
|
1859
1862
|
return this._processor ? (_a = this._processor.getVar(variableName)) != null ? _a : null : null;
|
|
1860
1863
|
}
|
|
@@ -2000,8 +2003,8 @@ var JsPdfDynamo = class {
|
|
|
2000
2003
|
case "Include".toLowerCase():
|
|
2001
2004
|
yield this.includeFile(processor, parameters);
|
|
2002
2005
|
return;
|
|
2003
|
-
case "
|
|
2004
|
-
yield this.
|
|
2006
|
+
case "IncludeUrl".toLowerCase():
|
|
2007
|
+
yield this.includeUrl(processor, parameters);
|
|
2005
2008
|
return;
|
|
2006
2009
|
case "IncVar".toLowerCase():
|
|
2007
2010
|
processor.incVar(parameters);
|
|
@@ -2139,12 +2142,12 @@ var JsPdfDynamo = class {
|
|
|
2139
2142
|
}
|
|
2140
2143
|
});
|
|
2141
2144
|
}
|
|
2142
|
-
|
|
2145
|
+
includeUrl(processor, input) {
|
|
2143
2146
|
return __async(this, null, function* () {
|
|
2144
2147
|
const subs = processor.substitute(input);
|
|
2145
|
-
__privateGet(this, _appLogger).debug(`.
|
|
2148
|
+
__privateGet(this, _appLogger).debug(`.includeUrl ${subs}`);
|
|
2146
2149
|
try {
|
|
2147
|
-
const response = yield (
|
|
2150
|
+
const response = yield fetch(subs, {
|
|
2148
2151
|
headers: { Accept: "text/plain;q=0.9, text/*;q=0.8, */*;q=0.7" }
|
|
2149
2152
|
});
|
|
2150
2153
|
if (!response.ok) {
|
package/dist/index.d.cts
CHANGED
|
@@ -6,7 +6,18 @@ interface ILogger {
|
|
|
6
6
|
info: (message: string, ...args: any | null) => void;
|
|
7
7
|
trace: (message: string, ...args: any | null) => void;
|
|
8
8
|
warn: (message: string, ...args: any | null) => void;
|
|
9
|
-
|
|
9
|
+
}
|
|
10
|
+
declare class AppLogger implements ILogger {
|
|
11
|
+
private _logLevel;
|
|
12
|
+
private _logger;
|
|
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;
|
|
19
|
+
logLevel(newLevel: string | number): void;
|
|
20
|
+
private canLog;
|
|
10
21
|
}
|
|
11
22
|
|
|
12
23
|
type fontStyleType = "bold" | "italic" | "normal" | "bolditalic";
|
|
@@ -291,7 +302,7 @@ declare class JsPdfProcessor {
|
|
|
291
302
|
get textColour(): string;
|
|
292
303
|
private set textColour(value);
|
|
293
304
|
private get pageCount();
|
|
294
|
-
constructor(options: Partial<IJsPdfOptions>, logger:
|
|
305
|
+
constructor(options: Partial<IJsPdfOptions>, logger: AppLogger);
|
|
295
306
|
private logAndParseCommand;
|
|
296
307
|
addBookmark(input: string): void;
|
|
297
308
|
addPage(input?: string): void;
|
|
@@ -354,8 +365,8 @@ declare class JsPdfDynamo {
|
|
|
354
365
|
_processor: JsPdfProcessor;
|
|
355
366
|
constructor(options?: Partial<IJsPdfOptions>, logger?: ILogger | null);
|
|
356
367
|
toBlob(): Blob | null;
|
|
357
|
-
toBlobUrl(): string | null;
|
|
358
|
-
|
|
368
|
+
toBlobUrl(fileName?: string): string | null;
|
|
369
|
+
getVariable(variableName: string): string | null;
|
|
359
370
|
private prepareNewPdf;
|
|
360
371
|
prepareWrappedString(input: string): string;
|
|
361
372
|
processCommands(commands: string[]): Promise<void>;
|
|
@@ -364,7 +375,7 @@ declare class JsPdfDynamo {
|
|
|
364
375
|
processGroups(processor: JsPdfProcessor, input: string, log?: boolean): Promise<void>;
|
|
365
376
|
private processGroupsRepeat;
|
|
366
377
|
private includeFile;
|
|
367
|
-
private
|
|
378
|
+
private includeUrl;
|
|
368
379
|
}
|
|
369
380
|
|
|
370
381
|
export { JsPdfDynamo };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,18 @@ interface ILogger {
|
|
|
6
6
|
info: (message: string, ...args: any | null) => void;
|
|
7
7
|
trace: (message: string, ...args: any | null) => void;
|
|
8
8
|
warn: (message: string, ...args: any | null) => void;
|
|
9
|
-
|
|
9
|
+
}
|
|
10
|
+
declare class AppLogger implements ILogger {
|
|
11
|
+
private _logLevel;
|
|
12
|
+
private _logger;
|
|
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;
|
|
19
|
+
logLevel(newLevel: string | number): void;
|
|
20
|
+
private canLog;
|
|
10
21
|
}
|
|
11
22
|
|
|
12
23
|
type fontStyleType = "bold" | "italic" | "normal" | "bolditalic";
|
|
@@ -291,7 +302,7 @@ declare class JsPdfProcessor {
|
|
|
291
302
|
get textColour(): string;
|
|
292
303
|
private set textColour(value);
|
|
293
304
|
private get pageCount();
|
|
294
|
-
constructor(options: Partial<IJsPdfOptions>, logger:
|
|
305
|
+
constructor(options: Partial<IJsPdfOptions>, logger: AppLogger);
|
|
295
306
|
private logAndParseCommand;
|
|
296
307
|
addBookmark(input: string): void;
|
|
297
308
|
addPage(input?: string): void;
|
|
@@ -354,8 +365,8 @@ declare class JsPdfDynamo {
|
|
|
354
365
|
_processor: JsPdfProcessor;
|
|
355
366
|
constructor(options?: Partial<IJsPdfOptions>, logger?: ILogger | null);
|
|
356
367
|
toBlob(): Blob | null;
|
|
357
|
-
toBlobUrl(): string | null;
|
|
358
|
-
|
|
368
|
+
toBlobUrl(fileName?: string): string | null;
|
|
369
|
+
getVariable(variableName: string): string | null;
|
|
359
370
|
private prepareNewPdf;
|
|
360
371
|
prepareWrappedString(input: string): string;
|
|
361
372
|
processCommands(commands: string[]): Promise<void>;
|
|
@@ -364,7 +375,7 @@ declare class JsPdfDynamo {
|
|
|
364
375
|
processGroups(processor: JsPdfProcessor, input: string, log?: boolean): Promise<void>;
|
|
365
376
|
private processGroupsRepeat;
|
|
366
377
|
private includeFile;
|
|
367
|
-
private
|
|
378
|
+
private includeUrl;
|
|
368
379
|
}
|
|
369
380
|
|
|
370
381
|
export { JsPdfDynamo };
|
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";
|
|
@@ -92,9 +89,6 @@ var AppLogger = class {
|
|
|
92
89
|
this._logLevel = newLevel;
|
|
93
90
|
}
|
|
94
91
|
}
|
|
95
|
-
if (this._logger.logLevel) {
|
|
96
|
-
this._logger.logLevel(this._logLevel);
|
|
97
|
-
}
|
|
98
92
|
}
|
|
99
93
|
canLog(level) {
|
|
100
94
|
return level >= this._logLevel;
|
|
@@ -331,8 +325,11 @@ var JsPdfProcessor = class {
|
|
|
331
325
|
this._variables.set("_DATEDMY", (/* @__PURE__ */ new Date()).toLocaleDateString("en-GB"));
|
|
332
326
|
this._variables.set("_PAGENO", "1");
|
|
333
327
|
this._variables.set("_PAGES", "1");
|
|
328
|
+
this.posnX = 0;
|
|
329
|
+
this.posnY = 0;
|
|
334
330
|
this.spaceHoz = 0;
|
|
335
331
|
this.spaceVert = 0;
|
|
332
|
+
this.currentPageNumber = 1;
|
|
336
333
|
this.lineWidth = this.pointsToUom(mmToPoints(0.2));
|
|
337
334
|
this.lineColour = "black";
|
|
338
335
|
this.fontPointSize = 12;
|
|
@@ -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 =
|
|
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
|
}
|
|
@@ -1166,10 +1164,16 @@ var JsPdfProcessor = class {
|
|
|
1166
1164
|
return;
|
|
1167
1165
|
}
|
|
1168
1166
|
let lastObjectHeight = 0;
|
|
1169
|
-
text = text.replace(
|
|
1167
|
+
text = text.replace(/\\[nN]/g, " \n") + " ";
|
|
1168
|
+
const splitText = text.split("\n");
|
|
1169
|
+
const lines = [];
|
|
1170
|
+
for (let line of splitText) {
|
|
1171
|
+
lines.push(...this._pdfDocument.splitTextToSize(line, maxWidth));
|
|
1172
|
+
}
|
|
1173
|
+
if (lines.length > splitText.length) {
|
|
1174
|
+
this._logger.trace(`Text was wrapped into ${lines.length} lines`, lines);
|
|
1175
|
+
}
|
|
1170
1176
|
this.posnY = top;
|
|
1171
|
-
const lines = this._pdfDocument.splitTextToSize(text, maxWidth) || [];
|
|
1172
|
-
this._logger.trace(`Text was wrapped into ${lines.length} lines`, lines);
|
|
1173
1177
|
while (lines.length > 0) {
|
|
1174
1178
|
if (!cmdGroup.startsWith("*")) {
|
|
1175
1179
|
yield jsPdfDynamo.processGroups(this, cmdGroup, false);
|
|
@@ -1321,8 +1325,8 @@ var JsPdfProcessor = class {
|
|
|
1321
1325
|
this.lastError = "Y Position resulted in negative value, adjusted to 0";
|
|
1322
1326
|
}
|
|
1323
1327
|
if (this.posnY > this._pageHeight) {
|
|
1328
|
+
this.lastError = `Y Position ${this.posnY} exceeded page ${this._currentPageNumber} height, adjusted to page height (${this._pageHeight})`;
|
|
1324
1329
|
this.posnY = this._pageHeight;
|
|
1325
|
-
this.lastError = "Y Position exceeded page height, adjusted to page height";
|
|
1326
1330
|
}
|
|
1327
1331
|
}
|
|
1328
1332
|
incVar(input) {
|
|
@@ -1811,12 +1815,11 @@ var JsPdfDynamo = class {
|
|
|
1811
1815
|
return null;
|
|
1812
1816
|
}
|
|
1813
1817
|
}
|
|
1814
|
-
toBlobUrl() {
|
|
1818
|
+
toBlobUrl(fileName) {
|
|
1815
1819
|
try {
|
|
1816
|
-
const result = this._processor.PdfDocument.output(
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
);
|
|
1820
|
+
const result = this._processor.PdfDocument.output("bloburi", {
|
|
1821
|
+
filename: fileName
|
|
1822
|
+
});
|
|
1820
1823
|
return result;
|
|
1821
1824
|
} catch (e) {
|
|
1822
1825
|
__privateGet(this, _appLogger).warn(
|
|
@@ -1825,7 +1828,7 @@ var JsPdfDynamo = class {
|
|
|
1825
1828
|
return null;
|
|
1826
1829
|
}
|
|
1827
1830
|
}
|
|
1828
|
-
|
|
1831
|
+
getVariable(variableName) {
|
|
1829
1832
|
var _a;
|
|
1830
1833
|
return this._processor ? (_a = this._processor.getVar(variableName)) != null ? _a : null : null;
|
|
1831
1834
|
}
|
|
@@ -1971,8 +1974,8 @@ var JsPdfDynamo = class {
|
|
|
1971
1974
|
case "Include".toLowerCase():
|
|
1972
1975
|
yield this.includeFile(processor, parameters);
|
|
1973
1976
|
return;
|
|
1974
|
-
case "
|
|
1975
|
-
yield this.
|
|
1977
|
+
case "IncludeUrl".toLowerCase():
|
|
1978
|
+
yield this.includeUrl(processor, parameters);
|
|
1976
1979
|
return;
|
|
1977
1980
|
case "IncVar".toLowerCase():
|
|
1978
1981
|
processor.incVar(parameters);
|
|
@@ -2110,12 +2113,12 @@ var JsPdfDynamo = class {
|
|
|
2110
2113
|
}
|
|
2111
2114
|
});
|
|
2112
2115
|
}
|
|
2113
|
-
|
|
2116
|
+
includeUrl(processor, input) {
|
|
2114
2117
|
return __async(this, null, function* () {
|
|
2115
2118
|
const subs = processor.substitute(input);
|
|
2116
|
-
__privateGet(this, _appLogger).debug(`.
|
|
2119
|
+
__privateGet(this, _appLogger).debug(`.includeUrl ${subs}`);
|
|
2117
2120
|
try {
|
|
2118
|
-
const response = yield
|
|
2121
|
+
const response = yield fetch(subs, {
|
|
2119
2122
|
headers: { Accept: "text/plain;q=0.9, text/*;q=0.8, */*;q=0.7" }
|
|
2120
2123
|
});
|
|
2121
2124
|
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
|
|
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
|
|
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
|
|
|
@@ -11,26 +11,29 @@
|
|
|
11
11
|
.DrawText 0 %_CurrentY% Commands are described in a following chapter.
|
|
12
12
|
|
|
13
13
|
.incCurrentY %_FontHeight%
|
|
14
|
-
.
|
|
15
|
-
.
|
|
14
|
+
.SetVar CommandLine1 Variables are referenced by enclosing them in percentage symbols. For example, to write some
|
|
15
|
+
.SetVar CommandLine1 %CommandLine1% text at the current position on the page the following DrawText command can be used:
|
|
16
|
+
.Do CommandLine1
|
|
16
17
|
.incCurrentY %_FontHeight%
|
|
17
18
|
.SetVar CommandLine1 .DrawText %%%%_CurrentX%%%% %%%%_CurrentY%%%% Hello World!
|
|
18
|
-
.Do CommandLine2
|
|
19
|
+
.Do CommandLine2
|
|
19
20
|
.incCurrentY %_FontHeight%
|
|
20
|
-
.
|
|
21
|
-
.
|
|
21
|
+
.SetVar CommandLine1 Variables (and commands) are not case sensitive and the above command could also be given as:
|
|
22
|
+
.Do CommandLine1
|
|
22
23
|
.incCurrentY %_FontHeight%
|
|
23
24
|
.SetVar CommandLine1 .drawTEXT %%%%_currentX%%%% %%%%_CURRENTy%%%% Hello World!
|
|
24
25
|
.Do CommandLine2
|
|
25
26
|
.incCurrentY %_FontHeight%
|
|
26
|
-
|
|
27
|
-
.
|
|
28
|
-
.
|
|
27
|
+
|
|
28
|
+
.SetVar CommandLine1 Variables are stored as strings though there is a limited capability to perform arithmetic on
|
|
29
|
+
.SetVar CommandLine1 %CommandLine1% variables. For example, the .IncVar command can be used to add or subtract a number from
|
|
30
|
+
.SetVar CommandLine1 %CommandLine1% a variable.
|
|
31
|
+
.Do CommandLine1
|
|
29
32
|
.incCurrentY %_FontHeight%
|
|
33
|
+
|
|
30
34
|
.DrawText 0 %_CurrentY% Variables do not have to be assigned a value before being used.
|
|
31
35
|
.DrawText 0 %_CurrentY% The value of a variable referenced before being assigned a value is an empty string.
|
|
32
36
|
.incCurrentY %_FontHeight%
|
|
33
|
-
.
|
|
34
|
-
.
|
|
35
|
-
.
|
|
36
|
-
|
|
37
|
+
.SetVar CommandLine1 All variables are global, there is no scoping of variables within a group. A variable
|
|
38
|
+
.SetVar CommandLine1 %CommandLine1% defined within a group is available to commands run after that group.
|
|
39
|
+
.Do CommandLine1
|
|
@@ -3,44 +3,44 @@
|
|
|
3
3
|
|
|
4
4
|
.incCurrentY %halfLineGap%
|
|
5
5
|
.SetVar text JsPdfDynamo maintains and updates various variables as each command is processed. These
|
|
6
|
-
.SetVar text %text% variables can not be changed directly by using the SetVar command.
|
|
7
|
-
.DrawTextWrapped 0 %_CurrentY% %_PageWidth% CommandCheckPage %
|
|
6
|
+
.SetVar text %text% variables can not be changed directly by using the SetVar command.
|
|
7
|
+
.DrawTextWrapped 0 %_CurrentY% %_PageWidth% CommandCheckPage %text%
|
|
8
|
+
.incCurrentY %halfLineGap%
|
|
9
|
+
.SetVar text Note that unless otherwise stated, all distances and positions are in the unit of measure specified
|
|
10
|
+
.SetVar text %text% when creating the JsPdfDynamo object.
|
|
11
|
+
.DrawTextWrapped 0 %_CurrentY% %_PageWidth% CommandCheckPage %text%
|
|
8
12
|
.incCurrentY %halfLineGap%
|
|
9
13
|
.SetMargin L 20
|
|
10
14
|
|
|
11
15
|
.SetVar CommandLine1 _CurrentX
|
|
12
|
-
.SetVar CommandLine2 The current horizontal position on the page, relative to the left margin
|
|
13
|
-
.Do VariableLine
|
|
14
|
-
.SetVar CommandLine2 millimeters.
|
|
16
|
+
.SetVar CommandLine2 The current horizontal position on the page, relative to the left margin.
|
|
15
17
|
.Do VariableLine
|
|
16
18
|
|
|
17
19
|
.incCurrentY %halfLineGap%
|
|
18
20
|
.SetVar CommandLine1 _CurrentY
|
|
19
|
-
.SetVar CommandLine2 The current vertical position on the page, relative to the top margin
|
|
20
|
-
.Do VariableLine
|
|
21
|
-
.SetVar CommandLine2 millimeters.
|
|
21
|
+
.SetVar CommandLine2 The current vertical position on the page, relative to the top margin.
|
|
22
22
|
.Do VariableLine
|
|
23
23
|
|
|
24
24
|
.incCurrentY %halfLineGap%
|
|
25
25
|
.SetVar CommandLine1 _CurrentPageSize
|
|
26
|
-
.SetVar CommandLine2 The name of the last page size specified, for example, '
|
|
26
|
+
.SetVar CommandLine2 The name of the last page size specified, for example, 'a4', 'letter'.
|
|
27
27
|
.Do VariableLineWide
|
|
28
28
|
|
|
29
29
|
.incCurrentY %halfLineGap%
|
|
30
30
|
.SetVar CommandLine1 _CurrentPageOrientation
|
|
31
|
-
.SetVar CommandLine2 The last page orientation specified:
|
|
32
|
-
.Do VariableLineWide
|
|
33
|
-
.SetVar CommandLine2 0=Portrait (default) 1=Landscape
|
|
31
|
+
.SetVar CommandLine2 The last page orientation specified: 'portrait' or 'landscape'
|
|
34
32
|
.Do VariableLineWide
|
|
35
33
|
|
|
36
34
|
.incCurrentY %halfLineGap%
|
|
37
35
|
.SetVar CommandLine1 _FontHeight
|
|
38
|
-
.SetVar CommandLine2 The height of the current font
|
|
39
|
-
.
|
|
40
|
-
.
|
|
41
|
-
|
|
42
|
-
.
|
|
43
|
-
.
|
|
36
|
+
.SetVar CommandLine2 The height of the current font. This can be used to create a space between
|
|
37
|
+
.SetVar CommandLine2 %CommandLine2% paragraphs when used in conjunction with the incCurrentY command.
|
|
38
|
+
.Do VariableLineWrapped
|
|
39
|
+
|
|
40
|
+
.incCurrentY %halfLineGap%
|
|
41
|
+
.SetVar CommandLine1 _FontName
|
|
42
|
+
.SetVar CommandLine2 The name of the current font. For example, "helvetica", which is the default font.
|
|
43
|
+
.Do VariableLineWrapped
|
|
44
44
|
|
|
45
45
|
.incCurrentY %halfLineGap%
|
|
46
46
|
.SetVar CommandLine1 _FontPointSize
|
|
@@ -52,16 +52,9 @@
|
|
|
52
52
|
.SetVar CommandLine2 The current font style. For example, "normal" or "italic".
|
|
53
53
|
.Do VariableLine
|
|
54
54
|
|
|
55
|
-
.incCurrentY %halfLineGap%
|
|
56
|
-
.SetVar CommandLine1 _FontType
|
|
57
|
-
.SetVar CommandLine2 The name of the current font. For example, "Helvetica", which is the
|
|
58
|
-
.Do VariableLine
|
|
59
|
-
.SetVar CommandLine2 default font type.
|
|
60
|
-
.Do VariableLine
|
|
61
|
-
|
|
62
55
|
.incCurrentY %halfLineGap%
|
|
63
56
|
.SetVar CommandLine1 _ImageHeight
|
|
64
|
-
.SetVar CommandLine2 The height of the last loaded image
|
|
57
|
+
.SetVar CommandLine2 The height of the last loaded image.
|
|
65
58
|
.Do VariableLine
|
|
66
59
|
|
|
67
60
|
.incCurrentY %halfLineGap%
|
|
@@ -71,7 +64,7 @@
|
|
|
71
64
|
|
|
72
65
|
.incCurrentY %halfLineGap%
|
|
73
66
|
.SetVar CommandLine1 _ImageWidth
|
|
74
|
-
.SetVar CommandLine2 The width of the last loaded image
|
|
67
|
+
.SetVar CommandLine2 The width of the last loaded image.
|
|
75
68
|
.Do VariableLine
|
|
76
69
|
|
|
77
70
|
.incCurrentY %halfLineGap%
|
|
@@ -81,7 +74,7 @@
|
|
|
81
74
|
|
|
82
75
|
.incCurrentY %halfLineGap%
|
|
83
76
|
.SetVar CommandLine1 _LastError
|
|
84
|
-
.SetVar CommandLine2 A description of the last error encountered.
|
|
77
|
+
.SetVar CommandLine2 A description of the last error encountered.
|
|
85
78
|
.Do VariableLine
|
|
86
79
|
|
|
87
80
|
.incCurrentY %halfLineGap%
|
|
@@ -95,50 +88,46 @@
|
|
|
95
88
|
|
|
96
89
|
.incCurrentY %halfLineGap%
|
|
97
90
|
.SetVar CommandLine1 _LastObjectHeight
|
|
98
|
-
.SetVar CommandLine2 The height of the last object that has been
|
|
91
|
+
.SetVar CommandLine2 The height of the last object that has been drawn.
|
|
99
92
|
.Do VariableLine
|
|
100
93
|
|
|
101
94
|
.incCurrentY %halfLineGap%
|
|
102
95
|
.SetVar CommandLine1 _LastObjectWidth
|
|
103
|
-
.SetVar CommandLine2 The width of the last object that has been
|
|
96
|
+
.SetVar CommandLine2 The width of the last object that has been drawn.
|
|
104
97
|
.Do VariableLine
|
|
105
98
|
|
|
106
99
|
.incCurrentY %halfLineGap%
|
|
107
100
|
.SetVar CommandLine1 _LastOutline
|
|
108
101
|
.SetVar CommandLine2 This contains the number assigned to each outline entry when it is
|
|
109
|
-
.
|
|
110
|
-
.
|
|
111
|
-
.Do VariableLine
|
|
102
|
+
.SetVar CommandLine2 %CommandLine2% created. This is used when creating child outline entries.
|
|
103
|
+
.Do VariableLineWrapped
|
|
112
104
|
|
|
113
105
|
.incCurrentY %halfLineGap%
|
|
114
106
|
.SetVar CommandLine1 _LastResult
|
|
115
107
|
.SetVar CommandLine2 Most commands update this variable. If the command fails, this will be
|
|
116
|
-
.
|
|
117
|
-
.SetVar CommandLine2
|
|
118
|
-
.
|
|
119
|
-
.
|
|
120
|
-
.Do VariableLine
|
|
121
|
-
.SetVar CommandLine2 is returned in this variable.
|
|
122
|
-
.Do VariableLine
|
|
108
|
+
.SetVar CommandLine2 %CommandLine2% set to '0'. A successful command will set this to '1' or to some other
|
|
109
|
+
.SetVar CommandLine2 %CommandLine2% useful value. For example, when a new page is added, _LastResult
|
|
110
|
+
.SetVar CommandLine2 %CommandLine2% will contain the number of the added page.
|
|
111
|
+
.Do VariableLineWrapped
|
|
123
112
|
|
|
124
113
|
.incCurrentY %halfLineGap%
|
|
125
114
|
.SetVar CommandLine1 _MarginBottom
|
|
126
|
-
.SetVar CommandLine2 The current margin
|
|
115
|
+
.SetVar CommandLine2 The current margin from the bottom edge of the page.
|
|
127
116
|
.Do VariableLine
|
|
128
117
|
|
|
129
118
|
.incCurrentY %halfLineGap%
|
|
130
119
|
.SetVar CommandLine1 _MarginLeft
|
|
131
|
-
.SetVar CommandLine2 The current margin
|
|
120
|
+
.SetVar CommandLine2 The current margin from the left edge of the page.
|
|
132
121
|
.Do VariableLine
|
|
133
122
|
|
|
134
123
|
.incCurrentY %halfLineGap%
|
|
135
124
|
.SetVar CommandLine1 _MarginRight
|
|
136
|
-
.SetVar CommandLine2 The current margin
|
|
125
|
+
.SetVar CommandLine2 The current margin from the right edge of the page.
|
|
137
126
|
.Do VariableLine
|
|
138
127
|
|
|
139
128
|
.incCurrentY %halfLineGap%
|
|
140
129
|
.SetVar CommandLine1 _MarginTop
|
|
141
|
-
.SetVar CommandLine2 The current margin
|
|
130
|
+
.SetVar CommandLine2 The current margin from the top edge of the page.
|
|
142
131
|
.Do VariableLine
|
|
143
132
|
|
|
144
133
|
.incCurrentY %halfLineGap%
|
|
@@ -148,9 +137,7 @@
|
|
|
148
137
|
|
|
149
138
|
.incCurrentY %halfLineGap%
|
|
150
139
|
.SetVar CommandLine1 _PageHeight
|
|
151
|
-
.SetVar CommandLine2 The height of the page, less the current top and bottom margins
|
|
152
|
-
.Do VariableLine
|
|
153
|
-
.SetVar CommandLine2 expressed in millimeters.
|
|
140
|
+
.SetVar CommandLine2 The height of the page, less the current top and bottom margins.
|
|
154
141
|
.Do VariableLine
|
|
155
142
|
|
|
156
143
|
.incCurrentY %halfLineGap%
|
|
@@ -160,31 +147,23 @@
|
|
|
160
147
|
|
|
161
148
|
.incCurrentY %halfLineGap%
|
|
162
149
|
.SetVar CommandLine1 _PageWidth
|
|
163
|
-
.SetVar CommandLine2 The width of the page, less the current left and right margins
|
|
164
|
-
.Do VariableLine
|
|
165
|
-
.SetVar CommandLine2 in millimeters.
|
|
150
|
+
.SetVar CommandLine2 The width of the page, less the current left and right margins.
|
|
166
151
|
.Do VariableLine
|
|
167
152
|
|
|
168
153
|
.incCurrentY %halfLineGap%
|
|
169
154
|
.SetVar CommandLine1 _SpaceHoz
|
|
170
155
|
.SetVar CommandLine2 JsPdfDynamo keeps track of the current position, relative to the left
|
|
171
|
-
.
|
|
172
|
-
.SetVar CommandLine2
|
|
173
|
-
.
|
|
174
|
-
.
|
|
175
|
-
.Do VariableLine
|
|
176
|
-
.SetVar CommandLine2 which can be set with the SetSpaceHoz command.
|
|
177
|
-
.Do VariableLine
|
|
156
|
+
.SetVar CommandLine2 %CommandLine2% margin, after each object is output. This position is calculated
|
|
157
|
+
.SetVar CommandLine2 %CommandLine2% from the width of the object plus the current horizontal spacing,
|
|
158
|
+
.SetVar CommandLine2 %CommandLine2% which can be set with the SetSpaceHoz command.
|
|
159
|
+
.Do VariableLineWrapped
|
|
178
160
|
|
|
179
161
|
.incCurrentY %halfLineGap%
|
|
180
162
|
.SetVar CommandLine1 _SpaceVert
|
|
181
|
-
.SetVar CommandLine2 JsPdfDynamo keeps track of the current position,
|
|
182
|
-
.
|
|
183
|
-
.SetVar CommandLine2
|
|
184
|
-
.
|
|
185
|
-
.
|
|
186
|
-
.Do VariableLine
|
|
187
|
-
.SetVar CommandLine2 be set with the SetSpaceVert command.
|
|
188
|
-
.Do VariableLine
|
|
163
|
+
.SetVar CommandLine2 %CommandLine2% JsPdfDynamo keeps track of the current position, relative
|
|
164
|
+
.SetVar CommandLine2 %CommandLine2% to the top margin, after each object is output. This position is calculated
|
|
165
|
+
.SetVar CommandLine2 %CommandLine2% from the height of the object plus the current vertical spacing, which can
|
|
166
|
+
.SetVar CommandLine2 %CommandLine2% be set with the SetSpaceVert command.
|
|
167
|
+
.Do VariableLineWrapped
|
|
189
168
|
.incCurrentY %_SPACEVERT%
|
|
190
169
|
.Do SetMargins
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
.SetVar CommandLine1 Create a top level bookmark entry for the current page:
|
|
35
35
|
.Do CommandLine
|
|
36
36
|
.incCurrentY %halfLineGap%
|
|
37
|
-
.SetVar CommandLine1 .AddBookmark
|
|
37
|
+
.SetVar CommandLine1 .AddBookmark 0 %%%%_PAGENO%%%% Chapter one of the document
|
|
38
38
|
.Do CommandLine2
|
|
39
|
-
.SetVar CommandLine1 .SetVar
|
|
39
|
+
.SetVar CommandLine1 .SetVar Chapter1 %%%%_LastResult%%%%
|
|
40
40
|
.Do CommandLine2
|
|
41
41
|
.incCurrentY %_FontHeight%
|
|
42
42
|
.SetVar CommandLine1 Create a child bookmark entry for the chapter 1:
|
|
43
43
|
.Do CommandLine
|
|
44
44
|
.incCurrentY %halfLineGap%
|
|
45
|
-
.SetVar CommandLine1 .AddBookmark
|
|
45
|
+
.SetVar CommandLine1 .AddBookmark %%%%Chapter1%%%% %%%%_PAGENO%%%% Chapter one, Paragraph 1
|
|
46
46
|
.Do CommandLine2
|
|
47
47
|
.incCurrentY %_FontHeight%
|