Skip to content

feat: column balancing for continuous section breaks #182

@jedrazb

Description

@jedrazb

Problem

When a continuous section break switches from single-column to multi-column layout, Word balances the content across columns so they end at roughly the same height. Our current implementation fills column 0 completely before overflowing to column 1 (sequential fill).

Word behavior:

┌──────────────┬──────────────┐
│ Paragraph 1  │ Paragraph 3  │
│ Paragraph 2  │ Paragraph 4  │
└──────────────┴──────────────┘

Current behavior:

┌──────────────┬──────────────┐
│ Paragraph 1  │              │
│ Paragraph 2  │              │
│ Paragraph 3  │              │
│ Paragraph 4  │              │
└──────────────┴──────────────┘

Context

Multi-column layout rendering was added in PR #175. The paginator correctly handles column advancement when content overflows, but it doesn't balance columns for continuous section breaks. Balancing only applies to continuous breaks — nextPage section breaks fill columns sequentially (top-to-bottom, left-to-right) as we currently do.

Implementation Notes

Column balancing requires:

  1. Detect when a continuous section break ends a multi-column section
  2. Calculate total content height for that section's blocks
  3. Binary search or iterative approach to find the optimal split point where all columns end at roughly the same Y position
  4. Re-layout the section's content with the balanced split

Test file: examples/vite/public/continuous-columns-test.docx demonstrates the issue.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions