jspdf-dynamo 1.0.0
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/LICENSE +8 -0
- package/README.md +93 -0
- package/dist/index.cjs +2175 -0
- package/dist/index.d.cts +370 -0
- package/dist/index.d.ts +370 -0
- package/dist/index.js +2145 -0
- package/documentation/1. Introduction/Introduction.txt +91 -0
- package/documentation/2. JsPdfDynamo/JsPdfDynamo.txt +6 -0
- package/documentation/2. JsPdfDynamo/constructor.txt +31 -0
- package/documentation/2. JsPdfDynamo/getVariable.txt +29 -0
- package/documentation/2. JsPdfDynamo/prepareWrappedString.txt +28 -0
- package/documentation/2. JsPdfDynamo/processCommands.txt +27 -0
- package/documentation/2. JsPdfDynamo/toBlob.txt +19 -0
- package/documentation/2. JsPdfDynamo/toBlobUrl.txt +36 -0
- package/documentation/3. Variables/Introduction.txt +36 -0
- package/documentation/3. Variables/SystemMaintained.txt +190 -0
- package/documentation/4. Commands/AddBookmark.txt +47 -0
- package/documentation/4. Commands/AddImageFromFile.txt +59 -0
- package/documentation/4. Commands/AddImageFromUrl.txt +63 -0
- package/documentation/4. Commands/AddPage.txt +40 -0
- package/documentation/4. Commands/CheckPage.txt +52 -0
- package/documentation/4. Commands/CopyVar.txt +52 -0
- package/documentation/4. Commands/Do.txt +40 -0
- package/documentation/4. Commands/DoRepeat.txt +51 -0
- package/documentation/4. Commands/DrawBox.txt +67 -0
- package/documentation/4. Commands/DrawDebugGrid.txt +41 -0
- package/documentation/4. Commands/DrawImage.txt +92 -0
- package/documentation/4. Commands/DrawLine.txt +62 -0
- package/documentation/4. Commands/DrawText.txt +61 -0
- package/documentation/4. Commands/DrawTextBox.txt +99 -0
- package/documentation/4. Commands/DrawTextWrapped.txt +65 -0
- package/documentation/4. Commands/ForEachPage.txt +44 -0
- package/documentation/4. Commands/GetEnvVar.txt +56 -0
- package/documentation/4. Commands/IfBlank.txt +63 -0
- package/documentation/4. Commands/IfGt.txt +58 -0
- package/documentation/4. Commands/IfNotBlank.txt +60 -0
- package/documentation/4. Commands/IncCurrentX.txt +52 -0
- package/documentation/4. Commands/IncCurrentY.txt +50 -0
- package/documentation/4. Commands/IncVar.txt +73 -0
- package/documentation/4. Commands/Include.txt +44 -0
- package/documentation/4. Commands/MultVar.txt +70 -0
- package/documentation/4. Commands/SetCurrentX.txt +37 -0
- package/documentation/4. Commands/SetCurrentY.txt +37 -0
- package/documentation/4. Commands/SetDocumentInfo.txt +35 -0
- package/documentation/4. Commands/SetFillColour.txt +58 -0
- package/documentation/4. Commands/SetFontName.txt +4 -0
- package/documentation/4. Commands/SetFontSize.txt +22 -0
- package/documentation/4. Commands/SetFontStyle.txt +55 -0
- package/documentation/4. Commands/SetLineColour.txt +58 -0
- package/documentation/4. Commands/SetLineWidth.txt +42 -0
- package/documentation/4. Commands/SetMargin.txt +69 -0
- package/documentation/4. Commands/SetPageOrientation.txt +42 -0
- package/documentation/4. Commands/SetVar.txt +69 -0
- package/documentation/5. Other Definitions/jsPdfOptions.txt +56 -0
- package/documentation/5. Other Definitions/logger.txt +35 -0
- package/documentation/5. Other Definitions/pageSizes.txt +41 -0
- package/documentation/6. Other/PossibleEnhancements.txt +63 -0
- package/documentation/6. Other/To Be Documented.txt +50 -0
- package/documentation/Documentation.pdf +9859 -0
- package/documentation/README.md +7 -0
- package/documentation/documentation.txt +266 -0
- package/documentation/gendoc.spec.ts +22 -0
- package/examples/1.Simple/simple.pdf +247 -0
- package/examples/1.Simple/template.txt +21 -0
- package/examples/examples.spec.ts +26 -0
- package/package.json +58 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
;
|
|
2
|
+
; jsPdf-Dynamo Documentation.
|
|
3
|
+
;
|
|
4
|
+
; Use this template to generate the documentation
|
|
5
|
+
;
|
|
6
|
+
.SetDocumentInfo author Stephen Corbett
|
|
7
|
+
.SetLineWidth 0.1
|
|
8
|
+
.SetFillColour lightgrey
|
|
9
|
+
.SetFontName helvetica
|
|
10
|
+
.SetSpaceVert 0.8
|
|
11
|
+
|
|
12
|
+
.SetVar themeColour red
|
|
13
|
+
.SetVar black black
|
|
14
|
+
.setVar codeBg 200 200 200
|
|
15
|
+
.SetVar halfLineGap 2.0
|
|
16
|
+
.SetLineColor %black%
|
|
17
|
+
|
|
18
|
+
.Do SetDefaultText
|
|
19
|
+
.SetVar margins 15
|
|
20
|
+
.SetVar marginB %margins%
|
|
21
|
+
.IncVar marginB %_FONTHEIGHT% 0.1
|
|
22
|
+
|
|
23
|
+
[SetMargins]
|
|
24
|
+
.SetMargin a %margins%
|
|
25
|
+
.SetMargin b %marginB%
|
|
26
|
+
[End]
|
|
27
|
+
|
|
28
|
+
[SetDefaultText]
|
|
29
|
+
.SetFontSize 11
|
|
30
|
+
.SetTextColour %black%
|
|
31
|
+
.SetFontStyle Normal
|
|
32
|
+
.Do SetHalfFontHeight
|
|
33
|
+
[End]
|
|
34
|
+
|
|
35
|
+
[SetHalfFontHeight]
|
|
36
|
+
.SetVar HalfFontHeight %_FontHeight%
|
|
37
|
+
.MultVar HalfFontHeight 0.5
|
|
38
|
+
[End]
|
|
39
|
+
|
|
40
|
+
[SetSmallFont]
|
|
41
|
+
.SetFontSize 7
|
|
42
|
+
.SetFontStyle Normal
|
|
43
|
+
.Do SetHalfFontHeight
|
|
44
|
+
[End]
|
|
45
|
+
|
|
46
|
+
[SetSmallFontBold]
|
|
47
|
+
.SetFontSize 7
|
|
48
|
+
.SetFontStyle Bold
|
|
49
|
+
.Do SetHalfFontHeight
|
|
50
|
+
[End]
|
|
51
|
+
|
|
52
|
+
[TitlePage]
|
|
53
|
+
.SetFontSize 36
|
|
54
|
+
.SetTextColour %themeColour%
|
|
55
|
+
.SetFontStyle Bold
|
|
56
|
+
.DrawBox 0 0 %_PageWidth% %_PageHeight% 0
|
|
57
|
+
.SetVar top %_PageHeight%
|
|
58
|
+
.MultVar top 0.3
|
|
59
|
+
.DrawTextBox 0 %top% %_PageWidth% %_FontHeight% centered top jsPdf-Dynamo
|
|
60
|
+
.SetFontSize 24
|
|
61
|
+
.SetTextColour %black%
|
|
62
|
+
.DrawTextBox 0 %_CurrentY% %_PageWidth% %_FontHeight% centered top User Guide
|
|
63
|
+
[End]
|
|
64
|
+
|
|
65
|
+
[ChapterHeading]
|
|
66
|
+
.AddPage
|
|
67
|
+
.do SetMargins
|
|
68
|
+
.SetFontSize 16
|
|
69
|
+
.SetTextColour %themeColour%
|
|
70
|
+
.SetFontStyle Bold
|
|
71
|
+
.IncVar ChapterNo 1
|
|
72
|
+
.AddBookmark 0 %_PAGENO% %ChapterNo%. %ChapterName%
|
|
73
|
+
.SetVar ChapterOutLine %_LastResult%
|
|
74
|
+
.DrawText 0 0 %ChapterNo%. %ChapterName%
|
|
75
|
+
.SetLineColor %themeColour%
|
|
76
|
+
.SetLineWidth 0.5
|
|
77
|
+
.DrawLine 0 %_CurrentY% %_PageWidth% %_CurrentY%
|
|
78
|
+
.do SetDefaultText
|
|
79
|
+
.incCurrentY %HalfFontHeight%
|
|
80
|
+
[End]
|
|
81
|
+
|
|
82
|
+
[Footer]
|
|
83
|
+
.SetVar top %_PageHeight%
|
|
84
|
+
.incVar top -%_FontHeight%
|
|
85
|
+
.ifGt %_PageNo% 1 .DrawTextBox 0 %top% %_PageWidth% %_FontHeight% centered centered Page %_PageNo% of %LastPage%
|
|
86
|
+
[End]
|
|
87
|
+
|
|
88
|
+
[CommandHeading]
|
|
89
|
+
.do SetMargins
|
|
90
|
+
.CheckPage 40
|
|
91
|
+
.SetFontSize 13
|
|
92
|
+
.SetTextColour %themeColour%
|
|
93
|
+
.SetFontStyle Bold
|
|
94
|
+
.addBookmark %ChapterOutLine% %_PAGENO% %CommandName%
|
|
95
|
+
.DrawText 0 %_CurrentY% %CommandName%
|
|
96
|
+
.do SetDefaultText
|
|
97
|
+
[End]
|
|
98
|
+
|
|
99
|
+
[CheckCommandOverflow]
|
|
100
|
+
.CheckPage %pageBottomMargin% CommandOverflow
|
|
101
|
+
[End]
|
|
102
|
+
|
|
103
|
+
[CommandOverflow]
|
|
104
|
+
.AddPage
|
|
105
|
+
.do SetMargins
|
|
106
|
+
.SetFontSize 14
|
|
107
|
+
.SetTextColour %themeColour%
|
|
108
|
+
.SetFontStyle Bold
|
|
109
|
+
.IfNotBlank CommandName .DrawText 0 %_CurrentY% %CommandName% (Continued)
|
|
110
|
+
.SetMargin L 20
|
|
111
|
+
.do SetDefaultText
|
|
112
|
+
.incCurrentY %halfLineGap%
|
|
113
|
+
[End]
|
|
114
|
+
|
|
115
|
+
[CommandSubHeading]
|
|
116
|
+
.incCurrentY %HalfFontHeight%
|
|
117
|
+
.CheckPage 10 CommandOverflow
|
|
118
|
+
.SetFontStyle Bold
|
|
119
|
+
.ifNe %_MarginLeft% 20 .SetMargin L 20
|
|
120
|
+
.DrawText 0 %_CurrentY% %CommandSubHeading%
|
|
121
|
+
.do SetDefaultText
|
|
122
|
+
[End]
|
|
123
|
+
|
|
124
|
+
[CommandCheckPage]
|
|
125
|
+
.CheckPage %_FONTHEIGHT% CommandOverflow
|
|
126
|
+
[End]
|
|
127
|
+
|
|
128
|
+
[CommandLine]
|
|
129
|
+
.CheckPage %_FONTHEIGHT% CommandOverflow
|
|
130
|
+
.DrawTextWrapped 0 %_CurrentY% %_PageWidth% CommandCheckPage %CommandLine1%
|
|
131
|
+
.SetVar CommandLine1
|
|
132
|
+
[End]
|
|
133
|
+
|
|
134
|
+
[CommandLine2]
|
|
135
|
+
.CheckPage %_FONTHEIGHT% CommandOverflow
|
|
136
|
+
.SetVar top %_CurrentY%
|
|
137
|
+
.SetVar cl1Width %_PageWidth%
|
|
138
|
+
.IncVar cl1Width -5
|
|
139
|
+
.SetVar cl1bWidth %_PageWidth%
|
|
140
|
+
.IncVar cl1bWidth -10
|
|
141
|
+
.SetVar cl2Width %_PageWidth%
|
|
142
|
+
.IncVar cl2Width -33
|
|
143
|
+
.SetVar cl3Width %_PageWidth%
|
|
144
|
+
.IncVar cl3Width -35
|
|
145
|
+
.ifNotBlank CommandLine1 .DrawTextWrapped 5 %top% %cl1Width% CommandCheckPage %CommandLine1%
|
|
146
|
+
.ifNotBlank CommandLine1b .DrawTextWrapped 10 %top% %cl1bWidth% CommandCheckPage %CommandLine1b%
|
|
147
|
+
.ifNotBlank CommandLine1c .DrawText 15 %top% %CommandLine1c%
|
|
148
|
+
.ifNotBlank CommandLine2 .DrawTextWrapped 33 %top% %cl2Width% CommandCheckPage %CommandLine2%
|
|
149
|
+
.ifNotBlank CommandLine3 .DrawTextWrapped 35 %top% %cl3Width% CommandCheckPage %CommandLine3%
|
|
150
|
+
.SetVar CommandLine1
|
|
151
|
+
.SetVar CommandLine1b
|
|
152
|
+
.SetVar CommandLine1c
|
|
153
|
+
.SetVar CommandLine2
|
|
154
|
+
.SetVar CommandLine3
|
|
155
|
+
[End]
|
|
156
|
+
|
|
157
|
+
[VariableLine]
|
|
158
|
+
.SetVar pageBottomMargin %_FONTHEIGHT%
|
|
159
|
+
.incVar pageBottomMargin %halfLineGap%
|
|
160
|
+
.CheckPage %pageBottomMargin% CommandOverflow
|
|
161
|
+
.SetVar top %_CurrentY%
|
|
162
|
+
.ifNotBlank CommandLine1 .DrawText 0 %top% %CommandLine1%
|
|
163
|
+
.ifNotBlank CommandLine2 .DrawText 38 %top% %CommandLine2%
|
|
164
|
+
.SetVar CommandLine1
|
|
165
|
+
.SetVar CommandLine2
|
|
166
|
+
[End]
|
|
167
|
+
|
|
168
|
+
[VariableLineWrapped]
|
|
169
|
+
.SetVar pageBottomMargin %_FONTHEIGHT%
|
|
170
|
+
.incVar pageBottomMargin %halfLineGap%
|
|
171
|
+
.SetVar maxWidth %_PageWidth%
|
|
172
|
+
.incVar maxWidth -38
|
|
173
|
+
.CheckPage %pageBottomMargin% CommandOverflow
|
|
174
|
+
.SetVar top %_CurrentY%
|
|
175
|
+
.ifNotBlank CommandLine1 .DrawText 0 %top% %CommandLine1%
|
|
176
|
+
.ifNotBlank CommandLine2 .DrawTextWrapped 38 %top% %maxWidth% CheckCommandOverflow %CommandLine2%
|
|
177
|
+
.SetVar CommandLine1
|
|
178
|
+
.SetVar CommandLine2
|
|
179
|
+
[End]
|
|
180
|
+
|
|
181
|
+
[VariableLineWide]
|
|
182
|
+
.SetVar pageBottomMargin %_FONTHEIGHT%
|
|
183
|
+
.incVar pageBottomMargin %halfLineGap%
|
|
184
|
+
.CheckPage %pageBottomMargin% CommandOverflow
|
|
185
|
+
.SetVar top %_CurrentY%
|
|
186
|
+
.ifNotBlank CommandLine1 .DrawText 0 %top% %CommandLine1%
|
|
187
|
+
.ifNotBlank CommandLine2 .DrawText 48 %top% %CommandLine2%
|
|
188
|
+
.SetVar CommandLine1
|
|
189
|
+
.SetVar CommandLine2
|
|
190
|
+
[End]
|
|
191
|
+
|
|
192
|
+
.do SetMargins TitlePage
|
|
193
|
+
.SetDocumentInfo Title jsPdf-Dynamo Developer's Documentation
|
|
194
|
+
.SetDocumentInfo Author Stephen Corbett
|
|
195
|
+
.SetDocumentInfo Creator jsPdf-Dynamo
|
|
196
|
+
.SetVar ChapterNo 0
|
|
197
|
+
|
|
198
|
+
.Include ./Documentation/1. Introduction/Introduction.txt
|
|
199
|
+
.Include ./Documentation/2. JsPdfDynamo/JsPdfDynamo.txt
|
|
200
|
+
.Include ./Documentation/2. JsPdfDynamo/constructor.txt
|
|
201
|
+
.Include ./Documentation/2. JsPdfDynamo/getVariable.txt
|
|
202
|
+
.Include ./Documentation/2. JsPdfDynamo/prepareWrappedString.txt
|
|
203
|
+
.Include ./Documentation/2. JsPdfDynamo/processCommands.txt
|
|
204
|
+
.Include ./Documentation/2. JsPdfDynamo/toBlob.txt
|
|
205
|
+
.Include ./Documentation/2. JsPdfDynamo/toBlobUrl.txt
|
|
206
|
+
|
|
207
|
+
.Include ./Documentation/3. Variables/Introduction.txt
|
|
208
|
+
.Include ./Documentation/3. Variables/SystemMaintained.txt
|
|
209
|
+
|
|
210
|
+
.SetVar ChapterName Commands
|
|
211
|
+
.do ChapterHeading
|
|
212
|
+
|
|
213
|
+
.Include ./Documentation/4. Commands/AddBookmark.txt
|
|
214
|
+
.Include ./Documentation/4. Commands/AddImageFromFile.txt
|
|
215
|
+
.Include ./Documentation/4. Commands/AddImageFromUrl.txt
|
|
216
|
+
.Include ./Documentation/4. Commands/AddPage.txt
|
|
217
|
+
.Include ./Documentation/4. Commands/CheckPage.txt
|
|
218
|
+
.Include ./Documentation/4. Commands/CopyVar.txt
|
|
219
|
+
.Include ./Documentation/4. Commands/Do.txt
|
|
220
|
+
.Include ./Documentation/4. Commands/DoRepeat.txt
|
|
221
|
+
.Include ./Documentation/4. Commands/DrawBox.txt
|
|
222
|
+
.Include ./Documentation/4. Commands/DrawDebugGrid.txt
|
|
223
|
+
.Include ./Documentation/4. Commands/DrawImage.txt
|
|
224
|
+
.Include ./Documentation/4. Commands/DrawLine.txt
|
|
225
|
+
.Include ./Documentation/4. Commands/DrawText.txt
|
|
226
|
+
.Include ./Documentation/4. Commands/DrawTextBox.txt
|
|
227
|
+
.Include ./Documentation/4. Commands/DrawTextWrapped.txt
|
|
228
|
+
.Include ./Documentation/4. Commands/ForEachPage.txt
|
|
229
|
+
.Include ./Documentation/4. Commands/IfBlank.txt
|
|
230
|
+
.Include ./Documentation/4. Commands/IfGt.txt
|
|
231
|
+
.Include ./Documentation/4. Commands/IfNotBlank.txt
|
|
232
|
+
.Include ./Documentation/4. Commands/incCurrentX.txt
|
|
233
|
+
.Include ./Documentation/4. Commands/incCurrentY.txt
|
|
234
|
+
.Include ./Documentation/4. Commands/Include.txt
|
|
235
|
+
.Include ./Documentation/4. Commands/IncVar.txt
|
|
236
|
+
.Include ./Documentation/4. Commands/MultVar.txt
|
|
237
|
+
.Include ./Documentation/4. Commands/setCurrentX.txt
|
|
238
|
+
.Include ./Documentation/4. Commands/setCurrentY.txt
|
|
239
|
+
.Include ./Documentation/4. Commands/SetDocumentInfo.txt
|
|
240
|
+
.Include ./Documentation/4. Commands/SetFillColour.txt
|
|
241
|
+
.Include ./Documentation/4. Commands/SetFontName.txt
|
|
242
|
+
.Include ./Documentation/4. Commands/SetFontSize.txt
|
|
243
|
+
.Include ./Documentation/4. Commands/SetFontStyle.txt
|
|
244
|
+
.Include ./Documentation/4. Commands/SetLineColour.txt
|
|
245
|
+
.Include ./Documentation/4. Commands/SetLineWidth.txt
|
|
246
|
+
.Include ./Documentation/4. Commands/SetMargin.txt
|
|
247
|
+
.Include ./Documentation/4. Commands/SetPageOrientation.txt
|
|
248
|
+
.Include ./Documentation/4. Commands/SetVar.txt
|
|
249
|
+
|
|
250
|
+
.SetVar ChapterName Other Definitions
|
|
251
|
+
.do ChapterHeading
|
|
252
|
+
.Include ./Documentation/5. Other Definitions/jsPdfOptions.txt
|
|
253
|
+
.Include ./Documentation/5. Other Definitions/logger.txt
|
|
254
|
+
.Include ./Documentation/5. Other Definitions/pageSizes.txt
|
|
255
|
+
|
|
256
|
+
.Include ./Documentation/6. Other/PossibleEnhancements.txt
|
|
257
|
+
.Include ./Documentation/6. Other/To Be Documented.txt
|
|
258
|
+
|
|
259
|
+
.SetVar LastPage %_PageNo%
|
|
260
|
+
.Do SetMargins SetDefaultText
|
|
261
|
+
.SetMargin b %margins%
|
|
262
|
+
.ForEachPage Footer
|
|
263
|
+
|
|
264
|
+
;.DrawDebugGrid
|
|
265
|
+
.SAVEpdF ./documentation/Documentation.pdf
|
|
266
|
+
.WriteLog info Documentation has been generated.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { expect, it, describe } from "vitest";
|
|
2
|
+
import { JsPdfDynamo } from "../src/jsPdfDynamo";
|
|
3
|
+
import { Logger } from "tslog";
|
|
4
|
+
import { ILogger } from "../src/models/logger";
|
|
5
|
+
|
|
6
|
+
describe("Build the documentation", () => {
|
|
7
|
+
it("should build", async () => {
|
|
8
|
+
const logger: ILogger = new Logger({
|
|
9
|
+
name: "jspdf-dynamo",
|
|
10
|
+
minLevel: 0,
|
|
11
|
+
type: "pretty",
|
|
12
|
+
});
|
|
13
|
+
const pdfDynamo = new JsPdfDynamo(
|
|
14
|
+
{ pageSize: "a4", orientation: "portrait" },
|
|
15
|
+
logger,
|
|
16
|
+
);
|
|
17
|
+
await pdfDynamo.processCommands([
|
|
18
|
+
".include ./documentation/documentation.txt",
|
|
19
|
+
]);
|
|
20
|
+
expect(true).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
%PDF-1.3
|
|
2
|
+
%�߬�
|
|
3
|
+
3 0 obj
|
|
4
|
+
<</Type /Page
|
|
5
|
+
/Parent 1 0 R
|
|
6
|
+
/Resources 2 0 R
|
|
7
|
+
/MediaBox [0 0 595.2799999999999727 841.8899999999999864]
|
|
8
|
+
/Contents 4 0 R
|
|
9
|
+
>>
|
|
10
|
+
endobj
|
|
11
|
+
4 0 obj
|
|
12
|
+
<<
|
|
13
|
+
/Length 278
|
|
14
|
+
>>
|
|
15
|
+
stream
|
|
16
|
+
0.5670000000000001 w
|
|
17
|
+
0 G
|
|
18
|
+
0.5669291338582678 w
|
|
19
|
+
0. G
|
|
20
|
+
1. g
|
|
21
|
+
2.2677165354330713 w
|
|
22
|
+
0. 0. 1. RG
|
|
23
|
+
27.2125984251968518 814.6774015748030706 543.1181102362205593 -775.5590551181103365 re
|
|
24
|
+
S
|
|
25
|
+
BT
|
|
26
|
+
/F2 36 Tf
|
|
27
|
+
36. TL
|
|
28
|
+
0. 0. 1. rg
|
|
29
|
+
188.9177952755905778 410.0317322834645211 Td
|
|
30
|
+
(This is a title) Tj
|
|
31
|
+
ET
|
|
32
|
+
endstream
|
|
33
|
+
endobj
|
|
34
|
+
1 0 obj
|
|
35
|
+
<</Type /Pages
|
|
36
|
+
/Kids [3 0 R ]
|
|
37
|
+
/Count 1
|
|
38
|
+
>>
|
|
39
|
+
endobj
|
|
40
|
+
5 0 obj
|
|
41
|
+
<<
|
|
42
|
+
/Type /Font
|
|
43
|
+
/BaseFont /Helvetica
|
|
44
|
+
/Subtype /Type1
|
|
45
|
+
/Encoding /WinAnsiEncoding
|
|
46
|
+
/FirstChar 32
|
|
47
|
+
/LastChar 255
|
|
48
|
+
>>
|
|
49
|
+
endobj
|
|
50
|
+
6 0 obj
|
|
51
|
+
<<
|
|
52
|
+
/Type /Font
|
|
53
|
+
/BaseFont /Helvetica-Bold
|
|
54
|
+
/Subtype /Type1
|
|
55
|
+
/Encoding /WinAnsiEncoding
|
|
56
|
+
/FirstChar 32
|
|
57
|
+
/LastChar 255
|
|
58
|
+
>>
|
|
59
|
+
endobj
|
|
60
|
+
7 0 obj
|
|
61
|
+
<<
|
|
62
|
+
/Type /Font
|
|
63
|
+
/BaseFont /Helvetica-Oblique
|
|
64
|
+
/Subtype /Type1
|
|
65
|
+
/Encoding /WinAnsiEncoding
|
|
66
|
+
/FirstChar 32
|
|
67
|
+
/LastChar 255
|
|
68
|
+
>>
|
|
69
|
+
endobj
|
|
70
|
+
8 0 obj
|
|
71
|
+
<<
|
|
72
|
+
/Type /Font
|
|
73
|
+
/BaseFont /Helvetica-BoldOblique
|
|
74
|
+
/Subtype /Type1
|
|
75
|
+
/Encoding /WinAnsiEncoding
|
|
76
|
+
/FirstChar 32
|
|
77
|
+
/LastChar 255
|
|
78
|
+
>>
|
|
79
|
+
endobj
|
|
80
|
+
9 0 obj
|
|
81
|
+
<<
|
|
82
|
+
/Type /Font
|
|
83
|
+
/BaseFont /Courier
|
|
84
|
+
/Subtype /Type1
|
|
85
|
+
/Encoding /WinAnsiEncoding
|
|
86
|
+
/FirstChar 32
|
|
87
|
+
/LastChar 255
|
|
88
|
+
>>
|
|
89
|
+
endobj
|
|
90
|
+
10 0 obj
|
|
91
|
+
<<
|
|
92
|
+
/Type /Font
|
|
93
|
+
/BaseFont /Courier-Bold
|
|
94
|
+
/Subtype /Type1
|
|
95
|
+
/Encoding /WinAnsiEncoding
|
|
96
|
+
/FirstChar 32
|
|
97
|
+
/LastChar 255
|
|
98
|
+
>>
|
|
99
|
+
endobj
|
|
100
|
+
11 0 obj
|
|
101
|
+
<<
|
|
102
|
+
/Type /Font
|
|
103
|
+
/BaseFont /Courier-Oblique
|
|
104
|
+
/Subtype /Type1
|
|
105
|
+
/Encoding /WinAnsiEncoding
|
|
106
|
+
/FirstChar 32
|
|
107
|
+
/LastChar 255
|
|
108
|
+
>>
|
|
109
|
+
endobj
|
|
110
|
+
12 0 obj
|
|
111
|
+
<<
|
|
112
|
+
/Type /Font
|
|
113
|
+
/BaseFont /Courier-BoldOblique
|
|
114
|
+
/Subtype /Type1
|
|
115
|
+
/Encoding /WinAnsiEncoding
|
|
116
|
+
/FirstChar 32
|
|
117
|
+
/LastChar 255
|
|
118
|
+
>>
|
|
119
|
+
endobj
|
|
120
|
+
13 0 obj
|
|
121
|
+
<<
|
|
122
|
+
/Type /Font
|
|
123
|
+
/BaseFont /Times-Roman
|
|
124
|
+
/Subtype /Type1
|
|
125
|
+
/Encoding /WinAnsiEncoding
|
|
126
|
+
/FirstChar 32
|
|
127
|
+
/LastChar 255
|
|
128
|
+
>>
|
|
129
|
+
endobj
|
|
130
|
+
14 0 obj
|
|
131
|
+
<<
|
|
132
|
+
/Type /Font
|
|
133
|
+
/BaseFont /Times-Bold
|
|
134
|
+
/Subtype /Type1
|
|
135
|
+
/Encoding /WinAnsiEncoding
|
|
136
|
+
/FirstChar 32
|
|
137
|
+
/LastChar 255
|
|
138
|
+
>>
|
|
139
|
+
endobj
|
|
140
|
+
15 0 obj
|
|
141
|
+
<<
|
|
142
|
+
/Type /Font
|
|
143
|
+
/BaseFont /Times-Italic
|
|
144
|
+
/Subtype /Type1
|
|
145
|
+
/Encoding /WinAnsiEncoding
|
|
146
|
+
/FirstChar 32
|
|
147
|
+
/LastChar 255
|
|
148
|
+
>>
|
|
149
|
+
endobj
|
|
150
|
+
16 0 obj
|
|
151
|
+
<<
|
|
152
|
+
/Type /Font
|
|
153
|
+
/BaseFont /Times-BoldItalic
|
|
154
|
+
/Subtype /Type1
|
|
155
|
+
/Encoding /WinAnsiEncoding
|
|
156
|
+
/FirstChar 32
|
|
157
|
+
/LastChar 255
|
|
158
|
+
>>
|
|
159
|
+
endobj
|
|
160
|
+
17 0 obj
|
|
161
|
+
<<
|
|
162
|
+
/Type /Font
|
|
163
|
+
/BaseFont /ZapfDingbats
|
|
164
|
+
/Subtype /Type1
|
|
165
|
+
/FirstChar 32
|
|
166
|
+
/LastChar 255
|
|
167
|
+
>>
|
|
168
|
+
endobj
|
|
169
|
+
18 0 obj
|
|
170
|
+
<<
|
|
171
|
+
/Type /Font
|
|
172
|
+
/BaseFont /Symbol
|
|
173
|
+
/Subtype /Type1
|
|
174
|
+
/FirstChar 32
|
|
175
|
+
/LastChar 255
|
|
176
|
+
>>
|
|
177
|
+
endobj
|
|
178
|
+
2 0 obj
|
|
179
|
+
<<
|
|
180
|
+
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
|
181
|
+
/Font <<
|
|
182
|
+
/F1 5 0 R
|
|
183
|
+
/F2 6 0 R
|
|
184
|
+
/F3 7 0 R
|
|
185
|
+
/F4 8 0 R
|
|
186
|
+
/F5 9 0 R
|
|
187
|
+
/F6 10 0 R
|
|
188
|
+
/F7 11 0 R
|
|
189
|
+
/F8 12 0 R
|
|
190
|
+
/F9 13 0 R
|
|
191
|
+
/F10 14 0 R
|
|
192
|
+
/F11 15 0 R
|
|
193
|
+
/F12 16 0 R
|
|
194
|
+
/F13 17 0 R
|
|
195
|
+
/F14 18 0 R
|
|
196
|
+
>>
|
|
197
|
+
/XObject <<
|
|
198
|
+
>>
|
|
199
|
+
>>
|
|
200
|
+
endobj
|
|
201
|
+
19 0 obj
|
|
202
|
+
<<
|
|
203
|
+
/Producer (jsPDF 2.5.2)
|
|
204
|
+
/CreationDate (D:20240923184311+10'00')
|
|
205
|
+
>>
|
|
206
|
+
endobj
|
|
207
|
+
20 0 obj
|
|
208
|
+
<<
|
|
209
|
+
/Type /Catalog
|
|
210
|
+
/Pages 1 0 R
|
|
211
|
+
/OpenAction [3 0 R /FitH null]
|
|
212
|
+
/PageLayout /OneColumn
|
|
213
|
+
>>
|
|
214
|
+
endobj
|
|
215
|
+
xref
|
|
216
|
+
0 21
|
|
217
|
+
0000000000 65535 f
|
|
218
|
+
0000000481 00000 n
|
|
219
|
+
0000002298 00000 n
|
|
220
|
+
0000000015 00000 n
|
|
221
|
+
0000000152 00000 n
|
|
222
|
+
0000000538 00000 n
|
|
223
|
+
0000000663 00000 n
|
|
224
|
+
0000000793 00000 n
|
|
225
|
+
0000000926 00000 n
|
|
226
|
+
0000001063 00000 n
|
|
227
|
+
0000001186 00000 n
|
|
228
|
+
0000001315 00000 n
|
|
229
|
+
0000001447 00000 n
|
|
230
|
+
0000001583 00000 n
|
|
231
|
+
0000001711 00000 n
|
|
232
|
+
0000001838 00000 n
|
|
233
|
+
0000001967 00000 n
|
|
234
|
+
0000002100 00000 n
|
|
235
|
+
0000002202 00000 n
|
|
236
|
+
0000002546 00000 n
|
|
237
|
+
0000002632 00000 n
|
|
238
|
+
trailer
|
|
239
|
+
<<
|
|
240
|
+
/Size 21
|
|
241
|
+
/Root 20 0 R
|
|
242
|
+
/Info 19 0 R
|
|
243
|
+
/ID [ <2FACE2D36FA3E85F5DEA29CF7C8F21D9> <2FACE2D36FA3E85F5DEA29CF7C8F21D9> ]
|
|
244
|
+
>>
|
|
245
|
+
startxref
|
|
246
|
+
2736
|
|
247
|
+
%%EOF
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[Initialise]
|
|
2
|
+
.SetVar themeColour blue
|
|
3
|
+
.SetFontName helvetica
|
|
4
|
+
.SetSpaceVert = 0.3
|
|
5
|
+
.SetMargin a 10
|
|
6
|
+
.SetMargin b 15
|
|
7
|
+
[End]
|
|
8
|
+
|
|
9
|
+
[TitlePage]
|
|
10
|
+
.SetLineWidth 0.8
|
|
11
|
+
.SetLineColor %themeColour%
|
|
12
|
+
.DrawBox 0 0 %_PageWidth% %_PageHeight% 0
|
|
13
|
+
.SetFontSize 36
|
|
14
|
+
.SetTextColour %themeColour%
|
|
15
|
+
.SetFontStyle Bold
|
|
16
|
+
.DrawTextBox 0 0 %_PageWidth% %_PageHeight% center center %title%
|
|
17
|
+
[End]
|
|
18
|
+
|
|
19
|
+
[DrawPage]
|
|
20
|
+
.Do Initialise TitlePage
|
|
21
|
+
[End]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { expect, it, describe } from "vitest";
|
|
2
|
+
import { JsPdfDynamo } from "../src/jsPdfDynamo";
|
|
3
|
+
|
|
4
|
+
describe("app", () => {
|
|
5
|
+
it("1. Simple", async () => {
|
|
6
|
+
const pdfDynamo = new JsPdfDynamo({
|
|
7
|
+
pageSize: "a4",
|
|
8
|
+
orientation: "portrait",
|
|
9
|
+
unit: "mm",
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const commands = [
|
|
13
|
+
// Load the template
|
|
14
|
+
".include ./examples/1.Simple/template.txt",
|
|
15
|
+
// Set the title
|
|
16
|
+
".SetVar title This is a title",
|
|
17
|
+
// Process the template
|
|
18
|
+
".Do DrawPage",
|
|
19
|
+
// Save the pdf
|
|
20
|
+
".SavePdf ./examples/1.Simple/simple.pdf",
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
await pdfDynamo.processCommands(commands);
|
|
24
|
+
expect(true).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jspdf-dynamo",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Generate data driven PDFs from dynamic templates",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsup",
|
|
8
|
+
"build-docs": "vitest --dir ./documentation run",
|
|
9
|
+
"check-exports": "attw --pack . ",
|
|
10
|
+
"ci": "npm run test && npm run lint && npm run build && npm run check-format && npm run check-exports ",
|
|
11
|
+
"examples": "vitest --dir ./examples run",
|
|
12
|
+
"format": "prettier --write .",
|
|
13
|
+
"lint": "tsc",
|
|
14
|
+
"local-release": "changeset version && changeset publish",
|
|
15
|
+
"prepublishOnly": "npm run ci",
|
|
16
|
+
"check-format": "prettier --check .",
|
|
17
|
+
"test": "vitest --dir ./src run"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"dynamo",
|
|
21
|
+
"jsPdf",
|
|
22
|
+
"PDF",
|
|
23
|
+
"template",
|
|
24
|
+
"typescript"
|
|
25
|
+
],
|
|
26
|
+
"author": "Stephen Corbett",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"jspdf": "^2.5.1",
|
|
30
|
+
"node-fetch": "^3.3.2"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@arethetypeswrong/cli": "^0.15.4",
|
|
34
|
+
"@changesets/cli": "^2.27.8",
|
|
35
|
+
"@types/blob-stream": "^0.1.33",
|
|
36
|
+
"@types/jspdf": "^1.3.3",
|
|
37
|
+
"prettier": "^3.3.3",
|
|
38
|
+
"tslog": "^4.9.3",
|
|
39
|
+
"tsup": "^8.2.4",
|
|
40
|
+
"typescript": "^5.5.4",
|
|
41
|
+
"vitest": "^2.1.1"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"documentation",
|
|
46
|
+
"examples",
|
|
47
|
+
"README.md",
|
|
48
|
+
"LICENSE"
|
|
49
|
+
],
|
|
50
|
+
"type": "module",
|
|
51
|
+
"exports": {
|
|
52
|
+
"./package.json": "./package.json",
|
|
53
|
+
".": {
|
|
54
|
+
"import": "./dist/index.js",
|
|
55
|
+
"default": "./dist/index.cjs"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|