jspdf-dynamo 1.0.7 → 1.0.8
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 +5 -3
- package/dist/index.js +2 -0
- package/documentation/3. Variables/SystemMaintained.txt +6 -0
- package/documentation/4. Commands/SavePdf.txt +35 -2
- package/documentation/4. Commands/SelectPage.txt +27 -2
- package/documentation/4. Commands/SetFillColour.txt +1 -0
- package/documentation/4. Commands/SetFontName.txt +2 -0
- package/documentation/4. Commands/SetFontSize.txt +1 -0
- package/documentation/4. Commands/SetLineColour.txt +1 -0
- package/documentation/Documentation.pdf +0 -0
- package/documentation/documentation.txt +0 -6
- package/examples/{examples.spec.ts → 1.Simple/simple.spec.ts} +3 -3
- package/package.json +7 -5
package/dist/index.cjs
CHANGED
|
@@ -55,11 +55,11 @@ var __async = (__this, __arguments, generator) => {
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
// src/index.ts
|
|
58
|
-
var
|
|
59
|
-
__export(
|
|
58
|
+
var index_exports = {};
|
|
59
|
+
__export(index_exports, {
|
|
60
60
|
JsPdfDynamo: () => JsPdfDynamo
|
|
61
61
|
});
|
|
62
|
-
module.exports = __toCommonJS(
|
|
62
|
+
module.exports = __toCommonJS(index_exports);
|
|
63
63
|
|
|
64
64
|
// src/models/jsPdfProcessor.ts
|
|
65
65
|
var import_jspdf = __toESM(require("jspdf"), 1);
|
|
@@ -1630,6 +1630,7 @@ var JsPdfProcessor = class {
|
|
|
1630
1630
|
let subs = this.logAndParseCommand(".savePdf", input.trim());
|
|
1631
1631
|
if (isBrowser()) {
|
|
1632
1632
|
this.lastError = "SavePdf is not supported in the browser";
|
|
1633
|
+
this._logger.warn(this.lastError);
|
|
1633
1634
|
this.lastResult = "0";
|
|
1634
1635
|
return;
|
|
1635
1636
|
}
|
|
@@ -1665,6 +1666,7 @@ var JsPdfProcessor = class {
|
|
|
1665
1666
|
this.lastResult = pageNo.toString();
|
|
1666
1667
|
this.posnX = 0;
|
|
1667
1668
|
this.posnY = 0;
|
|
1669
|
+
this.lastResult = "1";
|
|
1668
1670
|
}
|
|
1669
1671
|
setCurrentFont(fontName, fontStyle) {
|
|
1670
1672
|
this._pdfDocument.setFont(fontName, fontStyle);
|
package/dist/index.js
CHANGED
|
@@ -1601,6 +1601,7 @@ var JsPdfProcessor = class {
|
|
|
1601
1601
|
let subs = this.logAndParseCommand(".savePdf", input.trim());
|
|
1602
1602
|
if (isBrowser()) {
|
|
1603
1603
|
this.lastError = "SavePdf is not supported in the browser";
|
|
1604
|
+
this._logger.warn(this.lastError);
|
|
1604
1605
|
this.lastResult = "0";
|
|
1605
1606
|
return;
|
|
1606
1607
|
}
|
|
@@ -1636,6 +1637,7 @@ var JsPdfProcessor = class {
|
|
|
1636
1637
|
this.lastResult = pageNo.toString();
|
|
1637
1638
|
this.posnX = 0;
|
|
1638
1639
|
this.posnY = 0;
|
|
1640
|
+
this.lastResult = "1";
|
|
1639
1641
|
}
|
|
1640
1642
|
setCurrentFont(fontName, fontStyle) {
|
|
1641
1643
|
this._pdfDocument.setFont(fontName, fontStyle);
|
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
.SetVar text Note that unless otherwise stated, all distances and positions are in the unit of measure specified
|
|
10
10
|
.SetVar text %text% when creating the JsPdfDynamo object.
|
|
11
11
|
.DrawTextWrapped 0 %_CurrentY% %_PageWidth% CommandCheckPage %text%
|
|
12
|
+
.SetVar text %text% variables can not be changed directly by using the SetVar command.
|
|
13
|
+
.DrawTextWrapped 0 %_CurrentY% %_PageWidth% CommandCheckPage %text%
|
|
14
|
+
.incCurrentY %halfLineGap%
|
|
15
|
+
.SetVar text Note that unless otherwise stated, all distances and positions are in the unit of measure specified
|
|
16
|
+
.SetVar text %text% when creating the JsPdfDynamo object.
|
|
17
|
+
.DrawTextWrapped 0 %_CurrentY% %_PageWidth% CommandCheckPage %text%
|
|
12
18
|
.incCurrentY %halfLineGap%
|
|
13
19
|
.SetMargin L 20
|
|
14
20
|
|
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
.SetVar CommandName SavePdf
|
|
2
2
|
.Do CommandHeading
|
|
3
|
-
.SetVar
|
|
4
|
-
.
|
|
3
|
+
.SetVar text Only available when running within Node.js, this command saves the current PDF to the given location.
|
|
4
|
+
.SetVar text %text% A warning will be logged if used within a browser.
|
|
5
|
+
.DrawTextWrapped 0 %_CurrentY% %_PageWidth% CommandCheckPage %text%
|
|
6
|
+
|
|
7
|
+
.SetVar CommandSubHeading Syntax
|
|
8
|
+
.Do CommandSubHeading
|
|
9
|
+
.SetVar CommandLine1 .SavePdf File-name
|
|
10
|
+
.Do CommandLine2
|
|
11
|
+
|
|
12
|
+
.SetVar CommandSubHeading Parameters
|
|
13
|
+
.Do CommandSubHeading
|
|
14
|
+
.SetVar CommandLine1 File-name
|
|
15
|
+
.SetVar CommandLine2 The path and name of the file to save. This can include
|
|
16
|
+
.Do CommandLine2
|
|
17
|
+
.SetVar CommandLine2 variables as well as constant text.
|
|
18
|
+
.Do CommandLine2
|
|
19
|
+
|
|
20
|
+
.SetVar CommandSubHeading Other
|
|
21
|
+
.Do CommandSubHeading
|
|
22
|
+
.SetVar text The variable _LastResult is set to '1' if the current PDF is saved, otherwise it is set to '0'
|
|
23
|
+
.SetVar text %text% and _LastError is set to a description of the problem.
|
|
24
|
+
.DrawTextWrapped 0 %_CurrentY% %_PageWidth% CommandCheckPage %text%
|
|
25
|
+
.incCurrentY %halfLineGap%
|
|
26
|
+
.SetVar text Note that the path must exist or this command will fail.
|
|
27
|
+
.DrawTextWrapped 0 %_CurrentY% %_PageWidth% CommandCheckPage %text%
|
|
28
|
+
.incCurrentY %halfLineGap%
|
|
29
|
+
.SetVar text If not given the default name of Document.pdf will be used.
|
|
30
|
+
.DrawTextWrapped 0 %_CurrentY% %_PageWidth% CommandCheckPage %text%
|
|
31
|
+
|
|
32
|
+
.SetVar CommandSubHeading Examples
|
|
33
|
+
.Do CommandSubHeading
|
|
34
|
+
.SetVar CommandLine1 .SavePdf ../output/invoice.pdf
|
|
35
|
+
.Do CommandLine2
|
|
36
|
+
.SetVar CommandLine1 .SavePdf %%%%savepath%%%%/%%%%customer%%%%.pdf
|
|
37
|
+
.Do CommandLine2
|
|
5
38
|
|
|
6
39
|
.incCurrentY %_FontHeight%
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
.SetVar CommandName SelectPage
|
|
2
2
|
.Do CommandHeading
|
|
3
|
-
.SetVar
|
|
4
|
-
.
|
|
3
|
+
.SetVar text This makes the given page active and sets the current left and top positions to zero.
|
|
4
|
+
.SetVar text %text% Subsequent commands will be relative to this page.
|
|
5
|
+
.DrawTextWrapped 0 %_CurrentY% %_PageWidth% CommandCheckPage %text%
|
|
6
|
+
|
|
7
|
+
.SetVar CommandSubHeading Syntax
|
|
8
|
+
.Do CommandSubHeading
|
|
9
|
+
.SetVar CommandLine1 .SelectPage Value
|
|
10
|
+
.Do CommandLine2
|
|
11
|
+
|
|
12
|
+
.SetVar CommandSubHeading Parameters
|
|
13
|
+
.Do CommandSubHeading
|
|
14
|
+
.SetVar CommandLine1 Value
|
|
15
|
+
.SetVar CommandLine2 The number of the page to make active. This is 1 based.
|
|
16
|
+
.Do CommandLine2
|
|
17
|
+
|
|
18
|
+
.SetVar CommandSubHeading Other
|
|
19
|
+
.Do CommandSubHeading
|
|
20
|
+
.SetVar text The variable _LastResult is set to '1' if the command is successful, otherwise it is set to '0'
|
|
21
|
+
.SetVar text %text% and _LastError is set to a description of the problem.
|
|
22
|
+
.DrawTextWrapped 0 %_CurrentY% %_PageWidth% CommandCheckPage %text%
|
|
23
|
+
|
|
24
|
+
.SetVar CommandSubHeading Examples
|
|
25
|
+
.Do CommandSubHeading
|
|
26
|
+
.SetVar CommandLine1 .SelectPage 7
|
|
27
|
+
.Do CommandLine2
|
|
28
|
+
.SetVar CommandLine1 .SelectPage %%%%_Pages%%%%
|
|
29
|
+
.Do CommandLine2
|
|
5
30
|
|
|
6
31
|
.incCurrentY %_FontHeight%
|
|
Binary file
|
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
.SetVar top %_PageHeight%
|
|
57
57
|
.MultVar top 0.3
|
|
58
58
|
.DrawTextBox 0 %top% %_PageWidth% %_FontHeight% centered top jsPdf-Dynamo
|
|
59
|
-
.DrawTextBox 0 %_CurrentY% %_PageWidth% %_FontHeight% centered top (Draft)
|
|
60
59
|
.incCurrentY 2
|
|
61
60
|
.SetFontSize 24
|
|
62
61
|
.SetTextColour %black%
|
|
@@ -81,11 +80,6 @@
|
|
|
81
80
|
[End]
|
|
82
81
|
|
|
83
82
|
[Footer]
|
|
84
|
-
.setMargin t 7
|
|
85
|
-
.setFontStyle Bold
|
|
86
|
-
.setFontSize 18
|
|
87
|
-
.SetTextColour red
|
|
88
|
-
.ifGt %_PageNo% 1 .DrawTextBox 0 0 %_PageWidth% 8 centered centered *** Draft ***
|
|
89
83
|
.Do SetDefaultText
|
|
90
84
|
.SetVar top %_PageHeight%
|
|
91
85
|
.incVar top -%_FontHeight%
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { expect, it, describe } from "vitest";
|
|
2
|
-
import { JsPdfDynamo } from "
|
|
2
|
+
import { JsPdfDynamo } from "../../src/jsPdfDynamo";
|
|
3
3
|
|
|
4
|
-
describe("
|
|
5
|
-
it("
|
|
4
|
+
describe("1. Simple example", () => {
|
|
5
|
+
it("Create", async () => {
|
|
6
6
|
const pdfDynamo = new JsPdfDynamo({
|
|
7
7
|
pageSize: "a4",
|
|
8
8
|
orientation: "portrait",
|
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jspdf-dynamo",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Generate data driven PDFs from dynamic templates",
|
|
5
|
-
"main": "dist/index.
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
6
8
|
"repository": {
|
|
7
9
|
"type": "git",
|
|
8
10
|
"url": "git+https://github.com/SteveCorbett/jsPdf-Dynamo"
|
|
@@ -33,7 +35,7 @@
|
|
|
33
35
|
"author": "Stephen Corbett <corbett@corbtech.com.au> (https://corbtech.com.au)",
|
|
34
36
|
"license": "MIT",
|
|
35
37
|
"dependencies": {
|
|
36
|
-
"jspdf": "^
|
|
38
|
+
"jspdf": "^4.1.0"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
41
|
"@arethetypeswrong/cli": "^0.15.4",
|
|
@@ -44,7 +46,7 @@
|
|
|
44
46
|
"tslog": "^4.9.3",
|
|
45
47
|
"tsup": "^8.2.4",
|
|
46
48
|
"typescript": "^5.5.4",
|
|
47
|
-
"vitest": "^
|
|
49
|
+
"vitest": "^4.0.18"
|
|
48
50
|
},
|
|
49
51
|
"files": [
|
|
50
52
|
"dist",
|
|
@@ -58,7 +60,7 @@
|
|
|
58
60
|
"./package.json": "./package.json",
|
|
59
61
|
".": {
|
|
60
62
|
"import": "./dist/index.js",
|
|
61
|
-
"
|
|
63
|
+
"require": "./dist/index.cjs"
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
}
|