Skip to content

feat: landscape page layout for wide views - #582

Merged
transitrix merged 4 commits into
mainfrom
methodology/540-landscape-pages
Sep 3, 2026
Merged

transitrix merged 4 commits into
mainfrom
methodology/540-landscape-pages

Conversation

@transitrix

@transitrix transitrix commented Sep 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

Implements automatic detection and CSS generation for wide views, applying landscape page layout without manual CSS class assignment.

What's new

Wide view detection in CSS generation:

  • Extends generatePagedMediaCss(metadata) to accept view specifications with width/height dimensions
  • Detects views where width > height and automatically applies page: landscape CSS rule
  • Sanitizes view IDs for safe CSS identifier generation

Landscape page handling:

  • A4 landscape page size correctly declared (842 × 595 pt)
  • Running footer adjusts to landscape page width (15mm margins)
  • Page-break-inside avoid ensures diagrams stay intact

Tests:

  • 47 test cases covering wide/portrait view detection, edge cases, special characters
  • All tests passing

Architecture

Wide view detection happens at CSS generation time:

  1. Caller provides view specifications with width/height to generatePagedMediaCss()
  2. Module detects wide views (width > height) and generates CSS selectors
  3. HTML elements with matching id automatically render on landscape pages
  4. No manual class assignment needed; detection is automatic

Integration example

const metadata = {
  issuer: 'Acme Corp',
  document_identity: 'PRODUCT-MRD-1.0',
  views: [
    { id: 'diagram-arch', width: 1200, height: 600 }, // wide → landscape
    { id: 'diagram-flow', width: 400, height: 800 },  // portrait → portrait
  ],
};
const html = wrapHtmlForPrintRendering(content, metadata);
// diagram-arch renders on landscape page; diagram-flow on portrait page

Acceptance criteria met

✓ Wide views automatically use landscape pages
✓ Portrait views stay portrait
✓ Page size correctly declared (landscape A4: 842 × 595 pt)
✓ Layout is stable across renders

Part of larger work

This implements automatic landscape page detection for wide diagram views:

  • Engine selection and paged-media CSS specification (merged)
  • Running footer paged-media CSS (merged)
  • Wide view detection for landscape pages (this PR)

Testing

cd packages/document-renderer
node tests/test_paged_media_css.mjs

@transitrix
transitrix force-pushed the methodology/540-landscape-pages branch 2 times, most recently from 150ccd2 to e445cd1 Compare September 2, 2026 21:09
Adds automatic detection and CSS generation for wide views (width > height),
applying landscape page layout without manual class assignment.

- Extend generatePagedMediaCss() to accept view specifications
- Detect wide views and generate `page: landscape` CSS rules
- Sanitize view IDs for safe CSS identifier generation
- Add 9 new comprehensive tests for landscape page handling

Landscape pages use correct A4 rotated dimensions (842 × 595 pt) with
adjusted margins. Running footer adapts to landscape page width.

Acceptance criteria:
- Wide views automatically use landscape pages ✓
- Portrait views stay portrait ✓
- Page size correctly declared (landscape A4: 842 x 595 pt) ✓
- Layout is stable across renders ✓

Signed-off-by: transitrix <automation@transitrix.com>
@transitrix
transitrix force-pushed the methodology/540-landscape-pages branch from e445cd1 to 0b6132d Compare September 2, 2026 21:23
@transitrix transitrix changed the title feat: landscape page layout for wide views (epic #505, 4/4) feat: landscape page layout for wide views Sep 2, 2026
@transitrix
transitrix merged commit 121b019 into main Sep 3, 2026
11 checks passed
@transitrix
transitrix deleted the methodology/540-landscape-pages branch September 3, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant