ts-d2 0.0.21 → 0.0.22

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 CHANGED
@@ -80,23 +80,17 @@ All the supported DocumentElements are placed in the package `Deuterium.Content`
80
80
 
81
81
  ## Leaf elements
82
82
 
83
- The following leaf elements are currently supported:
84
- * Barcode
85
- * ColumnDefinition (only useful for page-based formats)
86
- * Directory
87
- * Footer
88
- * Formatted (may be used to directly insert docTYPE code and/or HTML code)
89
- * Header
90
- * Linebreak
91
- * Pagebreak
92
- * PageDefinition (only useful for page-based formats)
93
- * Paragraph
94
- * SpaceVertically
95
- * Span
96
- * Table
97
- * TableCell
98
- * TableRow
99
- * Text
83
+ Leaf elements have no children. The following leaf elements are supported:
84
+
85
+ * **Barcode** -- renders a barcode (QR, Code128, etc.) with configurable position, size and rotation
86
+ * **Linebreak** -- inserts a line break
87
+ * **Image** -- embeds an image with support for scaling, cropping, flipping, rotation and absolute positioning
88
+ * **Pagebreak** -- inserts a page break
89
+ * **Rule** -- draws a horizontal or vertical line with configurable style (solid, dashed, dotted, double, etc.), color and thickness
90
+ * **SpaceVertically** -- inserts vertical whitespace of a given height
91
+ * **Tag** -- inserts a named tag with optional parameters
92
+ * **Text** -- renders a plain text string
93
+ * **Variable** -- inserts a dynamic variable (data path, page number, date, etc.)
100
94
 
101
95
  Any leaf element may be added to multiple branch elements (there is no connection from a leaf element to its parent element).
102
96
 
@@ -118,6 +112,63 @@ new Deuterium.Content.Span("Hello World!", {
118
112
  });
119
113
  ```
120
114
 
115
+ ### Image
116
+
117
+ ```typescript
118
+ new Deuterium.Content.Image({
119
+ /* Currently only images located on the docPIPE server are supported. */
120
+ src: "logo.png",
121
+ alt: "Company Logo",
122
+ width: new Deuterium.Measure.AbsoluteMeasure(200, "pt"),
123
+ height: new Deuterium.Measure.AbsoluteMeasure(100, "pt"),
124
+ scaleType: "absolute",
125
+ });
126
+ ```
127
+
128
+ ### Variable
129
+
130
+ Variables can display dynamic data or special values like page numbers:
131
+
132
+ ```typescript
133
+ // Data variable
134
+ new Deuterium.Content.Variable({ path: "customer.name" });
135
+
136
+ // Page number
137
+ new Deuterium.Content.Variable({ specialType: "cur-page" });
138
+
139
+ // Total page count
140
+ new Deuterium.Content.Variable({ specialType: "page-count" });
141
+ ```
142
+
143
+ ### Rule
144
+
145
+ ```typescript
146
+ new Deuterium.Content.Rule({
147
+ width: new Deuterium.Measure.AbsoluteMeasure(400, "pt"),
148
+ thickness: new Deuterium.Measure.AbsoluteMeasure(1, "pt"),
149
+ color: Deuterium.Color.Colors.black,
150
+ style: "solid",
151
+ });
152
+ ```
153
+
154
+ ### Barcode
155
+
156
+ ```typescript
157
+ import Proto from "docframe-types";
158
+
159
+ new Deuterium.Content.Barcode({
160
+ type: Proto.ProtoBarcodeType.QRCODE,
161
+ data: "https://example.com",
162
+ x: new Deuterium.Measure.AbsoluteMeasure(0, "pt"),
163
+ y: new Deuterium.Measure.AbsoluteMeasure(0, "pt"),
164
+ width: new Deuterium.Measure.AbsoluteMeasure(100, "pt"),
165
+ height: new Deuterium.Measure.AbsoluteMeasure(100, "pt"),
166
+ referencePoint: "top-left",
167
+ rotation: 0,
168
+ positionAbsolute: false,
169
+ });
170
+ ```
171
+
121
172
  ## Branch elements
122
173
 
123
174
  Branch elements have two functionalities:
@@ -125,15 +176,31 @@ Branch elements have two functionalities:
125
176
  * Apply formatting/properties to their child elements.
126
177
 
127
178
  The following branch elements are supported:
128
- * Directory
129
- * Document
130
- * Footer
131
- * Header
132
- * Paragraph
133
- * Span
134
- * Table
135
- * TableCell
136
- * TableRow
179
+
180
+ * **AdjustHorizontally** -- adjusts font size within min/max bounds to fit content horizontally
181
+ * **AdvancedIllustrationArea** -- a positioned area for illustrations with text flow control
182
+ * **CarryOver** -- defines content carried over when a table breaks across pages
183
+ * **Condition** -- conditionally includes content based on a code expression
184
+ * **Directory** -- groups elements with optional name, editability and semantic type
185
+ * **Document** -- the root element; holds page/column definitions, paragraph formats and all content
186
+ * **Footer** -- defines page footer content with configurable mode (append, extend, replace)
187
+ * **Header** -- defines page header content with configurable mode (append, extend, replace)
188
+ * **Indentation** -- applies left/right indentation to its children
189
+ * **Link** -- wraps content in a hyperlink
190
+ * **Loop** -- iterates over a data path, rendering children for each entry
191
+ * **LoopEntry** -- represents a single entry inside a Loop
192
+ * **PageCondition** -- conditionally includes content evaluated per page
193
+ * **Paragraph** -- groups inline content under a named paragraph format with optional overrides
194
+ * **Section** -- defines a document section, optionally with its own column definition
195
+ * **Selection** -- groups selectable entries (single or multi-select)
196
+ * **SelectionEntry** -- a single option inside a Selection
197
+ * **Span** -- applies inline formatting (bold, italic, underline, strikethrough, color, sub/superscript)
198
+ * **SubTotal** -- defines a sub-total area for tables (e.g. running totals)
199
+ * **Table** -- a table element with configurable width, offset and repeating headers
200
+ * **TableCell** -- a table cell with alignment, background color, borders, padding, margin and rotation
201
+ * **TableContentGroup** -- groups table rows (e.g. header group, body group, footer group)
202
+ * **TableRow** -- a table row with optional minimum height
203
+ * **WsArea** -- wraps content to control widow/orphan and page-split behavior
137
204
 
138
205
  ### Content parameter
139
206
 
@@ -151,6 +218,108 @@ Especially the first variant of the content parameter can result in small code:
151
218
  new Deuterium.Content.Footer("...");
152
219
  ```
153
220
 
221
+ ### Span
222
+
223
+ ```typescript
224
+ new Deuterium.Content.Span("Important!", {
225
+ bold: true,
226
+ italic: true,
227
+ color: Deuterium.Color.Color.rgb(255, 0, 0),
228
+ underline: true,
229
+ });
230
+ ```
231
+
232
+ ### Link
233
+
234
+ ```typescript
235
+ new Deuterium.Content.Link("Click here", "https://example.com");
236
+ ```
237
+
238
+ ### Table
239
+
240
+ ```typescript
241
+ new Deuterium.Content.Table(
242
+ new Deuterium.Content.TableRow([
243
+ new Deuterium.Content.TableCell("Column 1", {
244
+ border: new Deuterium.Border.SideBorders({
245
+ bottom: new Deuterium.Border.Border(
246
+ new Deuterium.Measure.AbsoluteMeasure(1, "pt"),
247
+ Deuterium.Color.Colors.black,
248
+ ),
249
+ }),
250
+ }),
251
+ new Deuterium.Content.TableCell("Column 2"),
252
+ ]),
253
+ { repeatHeader: 1 },
254
+ );
255
+ ```
256
+
257
+ ### Header and Footer
258
+
259
+ ```typescript
260
+ new Deuterium.Content.Header("Page header content", { mode: "replace" });
261
+ new Deuterium.Content.Footer("Page footer content", { mode: "append" });
262
+ ```
263
+
264
+ ### Condition
265
+
266
+ ```typescript
267
+ new Deuterium.Content.Condition(
268
+ "This is only shown when the condition is true",
269
+ { code: "data.showSection === true", result: true },
270
+ );
271
+ ```
272
+
273
+ ### Loop
274
+
275
+ ```typescript
276
+ new Deuterium.Content.Loop(
277
+ new Deuterium.Content.Variable({ path: "item.name" }),
278
+ { path: "items" },
279
+ );
280
+ ```
281
+
282
+ ### Indentation
283
+
284
+ ```typescript
285
+ new Deuterium.Content.Indentation(
286
+ "This text is indented",
287
+ { left: new Deuterium.Measure.AbsoluteMeasure(30, "pt") },
288
+ );
289
+ ```
290
+
291
+ ## Support classes
292
+
293
+ In addition to the document elements, the library provides several support classes:
294
+
295
+ * **Deuterium.Alignment** -- predefined horizontal (Left, Center, Right, Justify, FullJustify) and vertical (Top, Middle, Bottom) alignment values
296
+ * **Deuterium.Border** -- `Border` (weight + color) and `SideBorders` (top/right/bottom/left)
297
+ * **Deuterium.Color** -- `Color.rgb()`, `Color.cmyk()`, `Color.fromHex()` factory methods and preset `Colors` (black, white)
298
+ * **Deuterium.Font** -- `Font` class and `StandardFonts` (Helvetica)
299
+ * **Deuterium.Measure** -- `AbsoluteMeasure` (pt, cm, mm, in, px), `Measure` (also supports %), `SideMeasures` and `Sides`
300
+ * **Deuterium.ParagraphFormat** -- defines named paragraph formats with font, size, line feed, spacing, alignment, bold/italic and indentation
301
+
302
+ ## Page layout
303
+
304
+ For page-based output formats (PDF, PostScript), you can configure page size and column layout:
305
+
306
+ ```typescript
307
+ const doc = new Deuterium.Content.Document("Content", {
308
+ pageDefinition: new Deuterium.Content.PageDefinition(
309
+ new Deuterium.Measure.AbsoluteMeasure(595, "pt"),
310
+ new Deuterium.Measure.AbsoluteMeasure(842, "pt"),
311
+ ),
312
+ columnDefinition: new Deuterium.Content.ColumnDefinition({
313
+ position: Deuterium.Content.ColumnPosition.Center,
314
+ interColumnSpace: new Deuterium.Measure.AbsoluteMeasure(0, "pt"),
315
+ positionOffset: new Deuterium.Measure.AbsoluteMeasure(70, "pt"),
316
+ width: new Deuterium.Measure.AbsoluteMeasure(490, "pt"),
317
+ }),
318
+ });
319
+ ```
320
+
321
+ Predefined page sizes are available via `PageDefinitions` (A3, A4, A5) and column presets via `ColumnDefinitions`.
322
+
154
323
  # Contributing
155
324
 
156
325
  Contributions to this project are very welcome. If you want to contribute, please create a pull request with your changes and a description of what you have done.
@@ -170,4 +339,4 @@ To run the tests, you can use the following command:
170
339
 
171
340
  ```bash
172
341
  npm run test
173
- ```
342
+ ```