Skip to content

Commit 033ba34

Browse files
authored
Add support for tables (#1577)
* Add page size utilities - Added page.contentWidth - Added page.contentHeight * Add table support - Tables support cell customization (including colors) - Tables also support rotatable text (with alignment support) - Tables have accessibility support * chore: fix code generation context - code generation now respects the current document positioning to allow use of page dependent operations * chore: remove comments from build * removed unnecessary config optimisations * Optimize table minification * Performance improvements to tables * Improve font handling in tables
1 parent ee7208b commit 033ba34

31 files changed

+2493
-47
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Add support for dynamic sizing
88
- Add support for rotatable text
99
- Fix page cascade options when text overflows
10+
- Add table generation
1011

1112
### [v0.16.0] - 2024-12-29
1213

docs/generate.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ class Node {
207207
({ y } = doc);
208208
doc.x = doc.y = 0;
209209

210+
// Update the page width for those which rely on the width of the document
211+
var docPageWidth = doc.page.width;
212+
var docPageHeight = doc.page.height;
213+
var docPageMargins = doc.page.margins;
214+
doc.page.width = doc.page.width - x - doc.page.margins.right;
215+
doc.page.margins = { top: 0, left: 0, right: 0, bottom: 0 };
216+
210217
// run the example code with the document
211218
vm.runInNewContext(this.code, {
212219
doc,
@@ -218,6 +225,9 @@ class Node {
218225
doc.restore();
219226
doc.x = x;
220227
doc.y = y + this.height;
228+
doc.page.width = docPageWidth;
229+
doc.page.height = docPageHeight;
230+
doc.page.margins = docPageMargins;
221231
break;
222232
case 'hr':
223233
doc.addPage();
@@ -226,6 +236,12 @@ class Node {
226236
// loop through subnodes and render them
227237
for (let index = 0; index < this.content.length; index++) {
228238
const fragment = this.content[index];
239+
240+
if (this.type === 'numberlist') {
241+
let node = new Node(['inlinecode', `${index + 1}. `]);
242+
fragment.content.splice(0, 0, node);
243+
}
244+
229245
if (fragment.type === 'text') {
230246
// add a new page for each heading, unless it follows another heading
231247
if (
@@ -328,5 +344,6 @@ render(doc, 'forms.md');
328344
render(doc, 'destinations.md');
329345
render(doc, 'attachments.md');
330346
render(doc, 'accessibility.md');
347+
render(doc, 'table.md');
331348
render(doc, 'you_made_it.md');
332349
doc.end();

docs/generate_website.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const files = [
2424
'destinations.md',
2525
'attachments.md',
2626
'accessibility.md',
27+
'table.md',
2728
'you_made_it.md'
2829
];
2930

0 commit comments

Comments
 (0)