Skip to content

Commit

Permalink
chore: fix code generation context
Browse files Browse the repository at this point in the history
- code generation now respects the current document positioning to allow use of page dependent operations
  • Loading branch information
hollandjake committed Jan 15, 2025
1 parent d475732 commit 165f1a2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ class Node {
({ y } = doc);
doc.x = doc.y = 0;

// Update the page width for those which rely on the width of the document
var docPageWidth = doc.page.width;
var docPageHeight = doc.page.height;
var docPageMargins = doc.page.margins;
doc.page.width = doc.page.width - x - doc.page.margins.right;
doc.page.margins = { top: 0, left: 0, right: 0, bottom: 0 };

// run the example code with the document
vm.runInNewContext(this.code, {
doc,
Expand All @@ -218,6 +225,9 @@ class Node {
doc.restore();
doc.x = x;
doc.y = y + this.height;
doc.page.width = docPageWidth;
doc.page.height = docPageHeight;
doc.page.margins = docPageMargins;
break;
case 'hr':
doc.addPage();
Expand Down

0 comments on commit 165f1a2

Please sign in to comment.