Skip to content

feat: sections, headers of every kind and floating pictures both ways - #1

Merged
dskripchenko merged 1 commit into
mainfrom
feat/sections-and-floating-pictures
Oct 28, 2026
Merged

dskripchenko merged 1 commit into
mainfrom
feat/sections-and-floating-pictures

Conversation

@dskripchenko

Copy link
Copy Markdown
Owner

php-docx 1.18.0 brought several sections per document and floating pictures (dskripchenko/php-docx#10). The bridge read only $document->section, so it dropped every section after the first in fromDocument() and merged PhpWord's sections into one in toDocument().

Both ways now

  • Sections one to one: page size and orientation (a preset paper size, else the size as it is), margins, header/footer offsets, start (breakType: next page, continuous, even or odd page).
  • Headers and footers of every kind: default, first-page, even-page (even pages turn on PhpWord's evenAndOddHeaders). Before, only default ones were carried, and PhpWord's headers of every kind were merged into one list.
  • Floating pictures: Image::$position ↔ PhpWord's image style (positioning, posHorizontal/posVertical and their …Rel, marginLeft/marginTop in points, wrappingStyle). Origins php-docx has no case for read as the nearest one.

Fixed: pictures from php-docx were handed to PhpWord as a data: URL, which PhpWord 1.x rejects (InvalidImageException), so fromDocument() failed on any document with a picture. They go as bytes now.

Changed: fromDocument() sets each section's page from the document's page setup instead of PhpWord's default page.

Requires dskripchenko/php-docx ^1.18. README (en/ru/de/zh), the class docblock and CHANGELOG updated.

Tests (tests/SectionsAndFloatingTest.php): three sections to PhpWord (orientation, custom size, break type, header kinds, inherited headers); the same through PhpWord's own Word2007 writer and php-docx's reader; PhpWord sections to the AST (body, header kinds, page setup, start); a floating picture both ways; an inline picture stays inline. PHPUnit: 10 tests OK; PHPStan level 8: no errors.

🤖 Generated with Claude Code

A php-docx section per PhpWord section with its page setup and start;
default, first-page and even-page headers and footers; floating pictures
through PhpWord's image style. Pictures from php-docx now reach PhpWord as
bytes: a data: URL was rejected as an invalid image. Requires php-docx
^1.18.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dskripchenko
dskripchenko merged commit 70a906d into main Oct 28, 2026
4 checks passed
@dskripchenko dskripchenko mentioned this pull request Oct 28, 2026
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