jspdf-dynamo 1.0.5 → 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 +80 -33
- package/dist/index.d.cts +12 -10
- package/dist/index.d.ts +12 -10
- package/dist/index.js +80 -33
- package/documentation/1. Introduction/Introduction.txt +1 -1
- package/documentation/3. Variables/Introduction.txt +13 -12
- package/documentation/3. Variables/SystemMaintained.txt +40 -0
- package/documentation/4. Commands/DrawTextWrapped.txt +1 -1
- package/documentation/4. Commands/IfBlank.txt +1 -1
- package/documentation/4. Commands/IfNotBlank.txt +1 -1
- package/documentation/4. Commands/LoadImageFromFile.txt +2 -2
- package/documentation/4. Commands/LoadImageFromUrl.txt +2 -2
- 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/SetTextColour.txt +4 -2
- package/documentation/5. Other Definitions/pageSizes.txt +3 -3
- package/documentation/Documentation.pdf +0 -0
- 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
|
@@ -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
|
|
@@ -115,6 +135,16 @@
|
|
|
115
135
|
.SetVar CommandLine2 %CommandLine2% will contain the number of the added page.
|
|
116
136
|
.Do VariableLineWrapped
|
|
117
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
|
+
|
|
118
148
|
.incCurrentY %halfLineGap%
|
|
119
149
|
.SetVar CommandLine1 _MarginBottom
|
|
120
150
|
.SetVar CommandLine2 The current margin from the bottom edge of the page.
|
|
@@ -170,5 +200,15 @@
|
|
|
170
200
|
.SetVar CommandLine2 %CommandLine2% from the height of the object plus the current vertical spacing, which can
|
|
171
201
|
.SetVar CommandLine2 %CommandLine2% be set with the SetSpaceVert command.
|
|
172
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
|
|
173
213
|
.incCurrentY %_SPACEVERT%
|
|
174
214
|
.Do SetMargins
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
.Do CommandHeading
|
|
3
3
|
.SetVar CommandLine1 Draw text at the given point on the page, relative to the page margins, wrapping to one or more new lines
|
|
4
4
|
.SetVar CommandLine1 %CommandLine1% as required, and handling overflowing of pages.
|
|
5
|
-
.Do
|
|
5
|
+
.Do CommandLine
|
|
6
6
|
|
|
7
7
|
.SetVar CommandSubHeading Syntax
|
|
8
8
|
.Do CommandSubHeading
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
.SetVar CommandLine1 If successful then several other variables are also set:
|
|
25
25
|
.Do CommandLine
|
|
26
26
|
.incCurrentY %halfLineGap%
|
|
27
|
-
.SetVar CommandLine1c _ImageHeight is set to the height of the image
|
|
27
|
+
.SetVar CommandLine1c _ImageHeight is set to the height of the image.
|
|
28
28
|
.Do CommandLine2
|
|
29
29
|
.SetVar CommandLine1c _ImageHeightPx is set to the height of the image pixels.
|
|
30
30
|
.Do CommandLine2
|
|
31
|
-
.SetVar CommandLine1c _ImageWidth is set to the width of the image
|
|
31
|
+
.SetVar CommandLine1c _ImageWidth is set to the width of the image.
|
|
32
32
|
.Do CommandLine2
|
|
33
33
|
.SetVar CommandLine1c _ImageWidthPx is set to the width of the image pixels.
|
|
34
34
|
.Do CommandLine2
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
.SetVar CommandLine1 If successful then several other variables are also set:
|
|
25
25
|
.Do CommandLine
|
|
26
26
|
.incCurrentY %halfLineGap%
|
|
27
|
-
.SetVar CommandLine1c _ImageHeight is set to the height of the image
|
|
27
|
+
.SetVar CommandLine1c _ImageHeight is set to the height of the image.
|
|
28
28
|
.Do CommandLine2
|
|
29
29
|
.SetVar CommandLine1c _ImageHeightPx is set to the height of the image pixels.
|
|
30
30
|
.Do CommandLine2
|
|
31
|
-
.SetVar CommandLine1c _ImageWidth is set to the width of the image
|
|
31
|
+
.SetVar CommandLine1c _ImageWidth is set to the width of the image.
|
|
32
32
|
.Do CommandLine2
|
|
33
33
|
.SetVar CommandLine1c _ImageWidthPx is set to the width of the image pixels.
|
|
34
34
|
.Do CommandLine2
|
|
@@ -10,12 +10,14 @@
|
|
|
10
10
|
.SetVar CommandSubHeading Parameters
|
|
11
11
|
.Do CommandSubHeading
|
|
12
12
|
.SetVar CommandLine1 Colour
|
|
13
|
-
.SetVar CommandLine2 Either a CSS named colour or a hexadecimal RGB colour.
|
|
13
|
+
.SetVar CommandLine2 Either a CSS named colour or a hexadecimal RGB colour. This is a required parameter.
|
|
14
14
|
.Do CommandLine2
|
|
15
15
|
|
|
16
16
|
.SetVar CommandSubHeading Other
|
|
17
17
|
.Do CommandSubHeading
|
|
18
|
-
.SetVar CommandLine1 The variable _LastResult is set to '
|
|
18
|
+
.SetVar CommandLine1 The variable _LastResult is set to '0' by this command if the colour parameter is not
|
|
19
|
+
.SetVar CommandLine1 %CommandLine1% provided, otherwise it is set to '1'. The variable _FillColour is set
|
|
20
|
+
.SetVar CommandLine1 %CommandLine1% to the colour parameter.
|
|
19
21
|
.Do CommandLine
|
|
20
22
|
|
|
21
23
|
.SetVar CommandSubHeading Examples
|
|
@@ -1,6 +1,85 @@
|
|
|
1
1
|
.SetVar CommandName SetFontName
|
|
2
2
|
.Do CommandHeading
|
|
3
|
-
.SetVar CommandLine1
|
|
3
|
+
.SetVar CommandLine1 Select the font to be used for rendering text. Subsequent output of text
|
|
4
|
+
.SetVar CommandLine1 %CommandLine1% will continue to use this font until changed by another SetFontName command.
|
|
5
|
+
.Do CommandLine
|
|
6
|
+
|
|
7
|
+
.SetVar CommandSubHeading Syntax
|
|
8
|
+
.Do CommandSubHeading
|
|
9
|
+
.SetVar CommandLine1 .SetFontName font
|
|
10
|
+
.Do CommandLine2
|
|
11
|
+
|
|
12
|
+
.SetVar CommandSubHeading Parameters
|
|
13
|
+
.Do CommandSubHeading
|
|
14
|
+
.SetVar CommandLine1 font
|
|
15
|
+
.SetVar CommandLine2 The name of the font to use. This parameter is required. The default fonts that care available are:
|
|
16
|
+
.Do CommandLine2
|
|
17
|
+
.incCurrentY %halfLineGap%
|
|
18
|
+
.Do CommandCheckPage
|
|
19
|
+
.SetVar top %_CurrentY%
|
|
20
|
+
.SetVar CommandLine2 -
|
|
21
|
+
.Do CommandLine2
|
|
22
|
+
.setCurrentY %top%
|
|
23
|
+
.SetVar CommandLine3 Courier
|
|
24
|
+
.SetFontName Courier
|
|
25
|
+
.Do CommandLine2
|
|
26
|
+
|
|
27
|
+
.Do CommandCheckPage
|
|
28
|
+
.SetFontName Helvetica
|
|
29
|
+
.SetVar CommandLine2 -
|
|
30
|
+
.SetVar CommandLine3 Helvetica
|
|
31
|
+
.Do CommandLine2
|
|
32
|
+
|
|
33
|
+
.Do CommandCheckPage
|
|
34
|
+
.SetVar top %_CurrentY%
|
|
35
|
+
.SetVar CommandLine2 -
|
|
36
|
+
.SetVar CommandLine3 Symbol
|
|
37
|
+
.Do CommandLine2
|
|
38
|
+
.SetFontName Symbol
|
|
39
|
+
.setCurrentY %top%
|
|
40
|
+
.DrawText 50 %top% (Symbol)
|
|
41
|
+
|
|
42
|
+
.Do CommandCheckPage
|
|
43
|
+
.SetFontName Helvetica
|
|
44
|
+
.SetVar top %_CurrentY%
|
|
45
|
+
.SetVar CommandLine2 -
|
|
46
|
+
.Do CommandLine2
|
|
47
|
+
.SetVar CommandLine3 Times
|
|
48
|
+
.SetFontName Times
|
|
49
|
+
.setCurrentY %top%
|
|
50
|
+
.Do CommandLine2
|
|
51
|
+
|
|
52
|
+
.Do CommandCheckPage
|
|
53
|
+
.SetFontName Helvetica
|
|
54
|
+
.SetVar top %_CurrentY%
|
|
55
|
+
.SetVar CommandLine2 -
|
|
56
|
+
.SetVar CommandLine3 ZapfDingbats
|
|
57
|
+
.Do CommandLine2
|
|
58
|
+
.SetFontName ZapfDingbats
|
|
59
|
+
.DrawText 60 %top% (ZapfDingbats)
|
|
60
|
+
|
|
61
|
+
.SetFontName Helvetica
|
|
62
|
+
|
|
63
|
+
.SetVar CommandSubHeading Other
|
|
64
|
+
.Do CommandSubHeading
|
|
65
|
+
.SetVar CommandLine1 The font name is not case sensitive so can be either upper, lower or mixed case.
|
|
66
|
+
.Do CommandLine
|
|
67
|
+
.incCurrentY %halfLineGap%
|
|
68
|
+
.SetVar CommandLine1 If a valid font name is provided the variable _LastResult is set to '1' otherwise the current
|
|
69
|
+
.SetVar CommandLine1 %CommandLine1% font is unchanged and _LastResult is set to '0'.
|
|
70
|
+
.Do CommandLine
|
|
71
|
+
|
|
72
|
+
.SetVar CommandSubHeading Example
|
|
73
|
+
.Do CommandSubHeading
|
|
74
|
+
.SetVar CommandLine1 Set subsequent text to be in fixed width courier:
|
|
75
|
+
.Do CommandLine
|
|
76
|
+
.incCurrentY %halfLineGap%
|
|
77
|
+
.SetVar CommandLine1 .SetFontName courier
|
|
78
|
+
.Do CommandLine2
|
|
79
|
+
|
|
80
|
+
.SetVar CommandSubHeading See Also
|
|
81
|
+
.Do CommandSubHeading
|
|
82
|
+
.SetVar CommandLine1 DrawTextBox, DrawText, SetFontSize, SetFontStyle, SetTextColour
|
|
4
83
|
.Do CommandLine
|
|
5
84
|
|
|
6
85
|
.incCurrentY %_FontHeight%
|
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
.SetVar CommandName SetFontSize
|
|
2
2
|
.Do CommandHeading
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
.SetVar CommandLine1 Sets the size of text in points. Subsequent rendering of text will be this size
|
|
5
|
+
.SetVar CommandLine1 %CommandLine1% until changed by another SetFontSize command.
|
|
6
|
+
.Do CommandLine
|
|
7
|
+
|
|
8
|
+
.SetVar CommandSubHeading Syntax
|
|
9
|
+
.Do CommandSubHeading
|
|
10
|
+
.SetVar CommandLine1 .SetFontSize fontSize
|
|
11
|
+
.Do CommandLine2
|
|
12
|
+
|
|
13
|
+
.SetVar CommandSubHeading Parameters
|
|
14
|
+
.Do CommandSubHeading
|
|
15
|
+
.SetVar CommandLine1 fontSize
|
|
16
|
+
.SetVar CommandLine2 The size of the font in points. This parameter is required.
|
|
17
|
+
.Do CommandLine2
|
|
18
|
+
|
|
19
|
+
.SetVar CommandSubHeading Other
|
|
20
|
+
.Do CommandSubHeading
|
|
21
|
+
.SetVar CommandLine1 If a valid font size is provided the variable _LastResult is set to '1' otherwise the current
|
|
22
|
+
.SetVar CommandLine1 %CommandLine1% font size is unchanged and _LastResult is set to '0'.
|
|
23
|
+
.Do CommandLine
|
|
24
|
+
.incCurrentY %halfLineGap%
|
|
25
|
+
.SetVar CommandLine1 The variable _FontPointSize is set to the value provided on this command.
|
|
26
|
+
.Do CommandLine
|
|
27
|
+
.incCurrentY %halfLineGap%
|
|
28
|
+
.SetVar CommandLine1 The variable _FontHeight is set to the height of the current font multiplied by the
|
|
29
|
+
.SetVar CommandLine1 %CommandLine1% 'line height factor' (which is 1.15) to allow for the space between
|
|
30
|
+
.SetVar CommandLine1 %CommandLine1% lines within a paragraph. (This is known as 'kerning'.) Note that this value
|
|
31
|
+
.SetVar CommandLine1 %CommandLine1% is in the unit of measure specified when the instance of JsPdfDynamo was created.
|
|
32
|
+
.Do CommandLine
|
|
33
|
+
.incCurrentY %halfLineGap%
|
|
34
|
+
|
|
35
|
+
.SetVar CommandSubHeading Example
|
|
36
|
+
.Do CommandSubHeading
|
|
37
|
+
.SetVar CommandLine1 Set the size of subsequent text to be 24 points:
|
|
38
|
+
.Do CommandLine
|
|
39
|
+
.incCurrentY %halfLineGap%
|
|
40
|
+
.SetVar CommandLine1 .SetFontSize 24
|
|
41
|
+
.Do CommandLine2
|
|
42
|
+
|
|
43
|
+
.SetVar CommandSubHeading See Also
|
|
44
|
+
.Do CommandSubHeading
|
|
45
|
+
.SetVar CommandLine1 DrawTextBox, DrawText, SetFontName, SetFontStyle, SetTextColour
|
|
4
46
|
.Do CommandLine
|
|
5
47
|
|
|
6
48
|
.incCurrentY %_FontHeight%
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
.SetVar CommandName SetFontStyle
|
|
2
2
|
.Do CommandHeading
|
|
3
|
-
.
|
|
4
|
-
.SetVar CommandLine1 Subsequent
|
|
5
|
-
.
|
|
6
|
-
.SetVar CommandLine1 SetFontStyle command.
|
|
3
|
+
.SetVar CommandLine1 Apply the typographical emphasis for the current font. For example, normal, bold
|
|
4
|
+
.SetVar CommandLine1 %CommandLine1% or italic. Subsequent rendering of text will continue to use this
|
|
5
|
+
.SetVar CommandLine1 %CommandLine1% emphasis until changed by another SetFontStyle command.
|
|
7
6
|
.Do CommandLine
|
|
8
7
|
|
|
9
8
|
.SetVar CommandSubHeading Syntax
|
|
@@ -67,7 +66,7 @@
|
|
|
67
66
|
|
|
68
67
|
.SetVar CommandSubHeading See Also
|
|
69
68
|
.Do CommandSubHeading
|
|
70
|
-
.SetVar CommandLine1 DrawTextBox, DrawText,
|
|
69
|
+
.SetVar CommandLine1 DrawTextBox, DrawText, SetFontName, SetFontSize, SetTextColour
|
|
71
70
|
.Do CommandLine
|
|
72
71
|
|
|
73
72
|
.incCurrentY %_FontHeight%
|
|
@@ -10,11 +10,14 @@
|
|
|
10
10
|
.SetVar CommandSubHeading Parameters
|
|
11
11
|
.Do CommandSubHeading
|
|
12
12
|
.SetVar CommandLine1 Colour
|
|
13
|
-
.SetVar CommandLine2 Either a CSS named colour or a hexadecimal RGB colour.
|
|
13
|
+
.SetVar CommandLine2 Either a CSS named colour or a hexadecimal RGB colour. This is a required parameter.
|
|
14
|
+
.Do CommandLine2
|
|
14
15
|
|
|
15
16
|
.SetVar CommandSubHeading Other
|
|
16
17
|
.Do CommandSubHeading
|
|
17
|
-
.SetVar CommandLine1 The variable _LastResult is set to '
|
|
18
|
+
.SetVar CommandLine1 The variable _LastResult is set to '0' by this command if the colour parameter is not
|
|
19
|
+
.SetVar CommandLine1 %CommandLine1% provided, otherwise it is set to '1'. The variable _LineColour is set
|
|
20
|
+
.SetVar CommandLine1 %CommandLine1% to the colour parameter.
|
|
18
21
|
.Do CommandLine
|
|
19
22
|
|
|
20
23
|
.SetVar CommandSubHeading Examples
|
|
@@ -10,12 +10,14 @@
|
|
|
10
10
|
.SetVar CommandSubHeading Parameters
|
|
11
11
|
.Do CommandSubHeading
|
|
12
12
|
.SetVar CommandLine1 Colour
|
|
13
|
-
.SetVar CommandLine2 Either a CSS named colour or a hexadecimal RGB colour.
|
|
13
|
+
.SetVar CommandLine2 Either a CSS named colour or a hexadecimal RGB colour. This is a required parameter.
|
|
14
14
|
.Do CommandLine2
|
|
15
15
|
|
|
16
16
|
.SetVar CommandSubHeading Other
|
|
17
17
|
.Do CommandSubHeading
|
|
18
|
-
.SetVar CommandLine1 The variable _LastResult is set to '
|
|
18
|
+
.SetVar CommandLine1 The variable _LastResult is set to '0' by this command if the colour parameter is not
|
|
19
|
+
.SetVar CommandLine1 %CommandLine1% provided, otherwise it is set to '1'. The variable _TextColour is set
|
|
20
|
+
.SetVar CommandLine1 %CommandLine1% to the colour parameter.
|
|
19
21
|
.Do CommandLine
|
|
20
22
|
|
|
21
23
|
.SetVar CommandSubHeading Examples
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
.SetVar CommandSubHeading ISO 216 & ISO 269 (Metric)
|
|
9
9
|
.Do CommandSubHeading
|
|
10
|
-
.SetVar CommandLine1c %CommandLine2% - a0
|
|
10
|
+
.SetVar CommandLine1c %CommandLine2% - a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10
|
|
11
11
|
.Do CommandLine2
|
|
12
|
-
.SetVar CommandLine1c %CommandLine2% - b0
|
|
12
|
+
.SetVar CommandLine1c %CommandLine2% - b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10
|
|
13
13
|
.Do CommandLine2
|
|
14
|
-
.SetVar CommandLine1c %CommandLine2% - c0
|
|
14
|
+
.SetVar CommandLine1c %CommandLine2% - c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10
|
|
15
15
|
.Do CommandLine2
|
|
16
16
|
|
|
17
17
|
.SetVar CommandSubHeading Other
|
|
Binary file
|
|
@@ -10,25 +10,11 @@
|
|
|
10
10
|
endobj
|
|
11
11
|
4 0 obj
|
|
12
12
|
<<
|
|
13
|
-
/Length
|
|
13
|
+
/Length 189
|
|
14
|
+
/Filter /FlateDecode
|
|
14
15
|
>>
|
|
15
16
|
stream
|
|
16
|
-
|
|
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
|
|
17
|
+
x�M�;N@D{��%֟m�
|
|
32
18
|
endstream
|
|
33
19
|
endobj
|
|
34
20
|
1 0 obj
|
|
@@ -40,16 +26,6 @@ endobj
|
|
|
40
26
|
5 0 obj
|
|
41
27
|
<<
|
|
42
28
|
/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
29
|
/BaseFont /Helvetica-Bold
|
|
54
30
|
/Subtype /Type1
|
|
55
31
|
/Encoding /WinAnsiEncoding
|
|
@@ -57,154 +33,23 @@ endobj
|
|
|
57
33
|
/LastChar 255
|
|
58
34
|
>>
|
|
59
35
|
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
36
|
2 0 obj
|
|
179
37
|
<<
|
|
180
38
|
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
|
181
39
|
/Font <<
|
|
182
|
-
/
|
|
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
|
|
40
|
+
/F2 5 0 R
|
|
196
41
|
>>
|
|
197
42
|
/XObject <<
|
|
198
43
|
>>
|
|
199
44
|
>>
|
|
200
45
|
endobj
|
|
201
|
-
|
|
46
|
+
6 0 obj
|
|
202
47
|
<<
|
|
203
48
|
/Producer (jsPDF 2.5.2)
|
|
204
|
-
/CreationDate (D:
|
|
49
|
+
/CreationDate (D:20241002155924+10'00')
|
|
205
50
|
>>
|
|
206
51
|
endobj
|
|
207
|
-
|
|
52
|
+
7 0 obj
|
|
208
53
|
<<
|
|
209
54
|
/Type /Catalog
|
|
210
55
|
/Pages 1 0 R
|
|
@@ -213,35 +58,22 @@ endobj
|
|
|
213
58
|
>>
|
|
214
59
|
endobj
|
|
215
60
|
xref
|
|
216
|
-
0
|
|
61
|
+
0 8
|
|
217
62
|
0000000000 65535 f
|
|
218
|
-
|
|
219
|
-
|
|
63
|
+
0000000413 00000 n
|
|
64
|
+
0000000600 00000 n
|
|
220
65
|
0000000015 00000 n
|
|
221
66
|
0000000152 00000 n
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
|
67
|
+
0000000470 00000 n
|
|
68
|
+
0000000704 00000 n
|
|
69
|
+
0000000789 00000 n
|
|
238
70
|
trailer
|
|
239
71
|
<<
|
|
240
|
-
/Size
|
|
241
|
-
/Root
|
|
242
|
-
/Info
|
|
243
|
-
/ID [ <
|
|
72
|
+
/Size 8
|
|
73
|
+
/Root 7 0 R
|
|
74
|
+
/Info 6 0 R
|
|
75
|
+
/ID [ <057B68611040878E4A1ECADDBA2E3039> <057B68611040878E4A1ECADDBA2E3039> ]
|
|
244
76
|
>>
|
|
245
77
|
startxref
|
|
246
|
-
|
|
78
|
+
892
|
|
247
79
|
%%EOF
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
; Sample data. This would normally be generated by an application
|
|
2
|
+
.SetVar DocumentCaption INVOICE
|
|
3
|
+
.SetVar DocumentType Invoice
|
|
4
|
+
.SetVar DocumentNo A12345
|
|
5
|
+
.SetVar CustNo BZ1235
|
|
6
|
+
.SetVar CustRef 104581
|
|
7
|
+
|
|
8
|
+
.SetVar To1 Ship To
|
|
9
|
+
.SetVar Name1 Phoenix Auto Bits & Pieces
|
|
10
|
+
.SetVar Addr1Line1 777 W Chandler Blvd
|
|
11
|
+
.SetVar City1 Phoenix
|
|
12
|
+
.SetVar State1 AZ
|
|
13
|
+
.SetVar Zip1 85021
|
|
14
|
+
|
|
15
|
+
.SetVar To2 Charge To
|
|
16
|
+
.SetVar Name2 Barry's Spare Parts Group
|
|
17
|
+
.SetVar Addr2Line1 Level 43
|
|
18
|
+
.SetVar Addr2Line2 2072 41st Ave #6300
|
|
19
|
+
.SetVar City2 Santa Cruz
|
|
20
|
+
.SetVar State2 CA
|
|
21
|
+
.SetVar Zip2 95062
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { expect, it, describe } from "vitest";
|
|
2
|
+
import { JsPdfDynamo } from "../../src/jsPdfDynamo";
|
|
3
|
+
import * as allParts from "./parts.json";
|
|
4
|
+
|
|
5
|
+
describe("2.Invoice example", () => {
|
|
6
|
+
it("Create invoice", async () => {
|
|
7
|
+
const pdfDynamo = new JsPdfDynamo({
|
|
8
|
+
pageSize: "a4",
|
|
9
|
+
orientation: "portrait",
|
|
10
|
+
unit: "mm",
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const formatter = new Intl.NumberFormat(undefined, {
|
|
14
|
+
minimumFractionDigits: 2,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const commands = [
|
|
18
|
+
// Load the template
|
|
19
|
+
".include ./examples/2.Invoice/template.txt",
|
|
20
|
+
// Load some sample data. This would normally be generated by an application
|
|
21
|
+
".include ./examples/2.Invoice/data.txt",
|
|
22
|
+
`.setVar docDate ${new Date().toLocaleDateString()}`,
|
|
23
|
+
// Create the top section of the first page
|
|
24
|
+
".Do Initialise FirstPageHeader Headings",
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const total = addParts(commands, allParts.parts, 380, formatter);
|
|
28
|
+
commands.push(
|
|
29
|
+
`.setVar total ${formatter.format(total)}`,
|
|
30
|
+
".Do Totals",
|
|
31
|
+
".ForEachPage NumberPages",
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
commands.push(".SavePdf ./examples/2.Invoice/invoice.pdf");
|
|
35
|
+
|
|
36
|
+
await pdfDynamo.processCommands(commands);
|
|
37
|
+
expect(true).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function addParts(
|
|
42
|
+
commands: string[],
|
|
43
|
+
parts: any,
|
|
44
|
+
maxParts: number,
|
|
45
|
+
formatter: Intl.NumberFormat,
|
|
46
|
+
): number {
|
|
47
|
+
let result = 0;
|
|
48
|
+
for (let ix = 0; ix < parts.length && ix < maxParts; ix++) {
|
|
49
|
+
const part = parts[ix];
|
|
50
|
+
commands.push(`.setVar partNo ${part.partNumber}`);
|
|
51
|
+
commands.push(`.setVar description ${part.description}`);
|
|
52
|
+
const qty = Math.floor(Math.random() * 8);
|
|
53
|
+
commands.push(`.setVar qty ${qty === 0 ? "On Order" : qty}`);
|
|
54
|
+
commands.push(`.setVar price ${formatter.format(part.price)}`);
|
|
55
|
+
const total = qty * part.price;
|
|
56
|
+
commands.push(`.setVar total ${qty === 0 ? "-" : formatter.format(total)}`);
|
|
57
|
+
commands.push(`.SetVar ix ${ix + 1}`);
|
|
58
|
+
commands.push(`.Do AddPart`);
|
|
59
|
+
result += total;
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|