Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Various Missing Features in HTML Writer #2343

Closed
wants to merge 36 commits into from

Conversation

oleibman
Copy link
Contributor

@oleibman oleibman commented Dec 1, 2022

This PR supersedes #1814, which had become badly out of sync due to recent changes to the repository.

Implement a number of features implemented in PhpWord, but not yet supported in PhpWord HTML Writer.

  1. Use css @page and page declarations for sections.
  2. Wrap sections in div, with page break before each (except first).
  3. Add ability to specify generic fallback font for html (documentation change).
  4. Add ability to specify handling of whitespace in html (documentation change). Currently, Word writer preserves space but HTML writer does not.
  5. Support for Language, both for document overall and individual text elements.
  6. Support for PageBreak for HTML (currently only PDF is supported).
  7. Support for Table Border style, color, and size.
  8. Support for empty paragraphs (Word writer permits, browsers generally suppress).
  9. Default paragraph style should apply to all paragraphs, as well as class Normal.
  10. Paragraph style should support line-height.
  11. Paragraph style should support indentation.
  12. Paragraph style should support page-break-before.
  13. Paragraph style should not specify margin-top/bottom when spacing is null.

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.

Fixes # (issue)

Checklist:

  • I have run composer run-script check --timeout=0 and no errors were reported
  • The new code is covered by unit tests (check build/coverage for coverage report)
  • I have updated the documentation to describe the changes

This PR supersedes PHPOffice#1814, which had become badly out of sync due to recent changes to the repository.

Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord HTML Writer.

1. Use css @page and page declarations for sections.
2. Wrap sections in div, with page break before each (except first).
3. Add ability to specify generic fallback font for html (documentation change).
4. Add ability to specify handling of whitespace in html (documentation change).
   Currently, Word writer preserves space but HTML writer does not.
5. Support for Language, both for document overall and individual text elements.
6. Support for PageBreak for HTML (currently only PDF is supported).
7. Support for Table Border style, color, and size.
8. Support for empty paragraphs (Word writer permits, browsers generally suppress).
9. Default paragraph style should apply to all paragraphs, as well as class Normal.
10. Paragraph style should support line-height.
11. Paragraph style should support indentation.
12. Paragraph style should support page-break-before.
13. Paragraph style should not specify margin-top/bottom when spacing is null.
Use deprecated assertRegExp if its replacement is not available.
Catch Throwable instead.
Simple changes to address its new issues.
@oleibman
Copy link
Contributor Author

oleibman commented Dec 1, 2022

@Progi1984 This is the rebased version you requested for 1814. It passes all existing and new unit tests, as well as some additional tests I made.

It can run out of memory for large files, as in PhpSpreadsheet.
Restrict to PhpUnit 7, 8, or 9.
Try to satisfy Scrutinizer.
A mere 135 error reports.
Indentation values should not be permitted to be null.
Very minor improvement.
Correct some problems.
Several minor fixes, mostly to tests.
Make sure it captures Warnings, Notices, Deprecations.
Use E_ALL for error_reporting.
It handles page breaks with a different non-standard extension than the other PDF products. Also honor user's choice of paper rather than hardcoding A4.
No vertical spacing between paragraphs when user has explicitly spaceBefore and spaceAfter to 0 in default paragraph style.
Use Vertical Spacing when default spaceBefore and spaceAfter are numeric, not just zero.
TCPDF does not parse any of the CSS margin properties. Text-indent can be used as an imperfect margin-left replacement.
I had put typehint for private variable in code rather than comment.
Little in common, clearer code afterwards.
Little in common, code is now clearer.
Ensure `isPdf` is set in constructor so that `getContent` will be correct.
Many uses, e.g. adding headers and footers in Mpdf.
Use defined constant to include headers and footers in initial WriteHTML.
Specify direction as rtl for font style when rtl is true, and for paragraph style when bidi is true.
Add to Shared/HTML, update Writer Html/Odt/Rtf appropriately.
Annotate some intended use of deprecations.
Not limited to Html/Pdf, some changes were needed for Rtf and Odt as well.

Allow user to set default RTL setting applied to Paragraph, Font, and Table styles when they don't explicitly set a direction.
At least I hope it's momentary - couldn't initialize Php7.4 or 8.0, didn't attempt others.
@Progi1984 Progi1984 force-pushed the master branch 3 times, most recently from 2d9f999 to e458249 Compare August 30, 2023 11:56
oleibman added a commit to oleibman/PHPWord that referenced this pull request Sep 18, 2023
This PR supersedes PHPOffice#1814 and PHPOffice#2343, which had become badly out of sync due to recent changes to the repository.

Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord HTML Writer.

1. Use css @page and page declarations for sections.
2. Wrap sections in div, with page break before each (except first).
3. Add ability to specify generic fallback font for html (documentation change).
4. Add ability to specify handling of whitespace in html (documentation change).
   Currently, Word writer preserves space but HTML writer does not.
5. Support for Language, both for document overall and individual text elements.
6. Support for PageBreak for HTML (currently only PDF is supported).
7. Support for Table Border style, color, and size.
8. Support for empty paragraphs (Word writer permits, browsers generally suppress).
9. Default paragraph style should apply to all paragraphs, as well as class Normal.
10. Paragraph style should support line-height.
11. Paragraph style should support indentation.
12. Paragraph style should support page-break-before.
13. Paragraph style should not specify margin-top/bottom when spacing is null.
@oleibman
Copy link
Contributor Author

Superseded by #2475.

@oleibman oleibman closed this Sep 20, 2023
Progi1984 pushed a commit to oleibman/PHPWord that referenced this pull request Nov 8, 2023
This PR supersedes PHPOffice#1814 and PHPOffice#2343, which had become badly out of sync due to recent changes to the repository.

Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord HTML Writer.

1. Use css @page and page declarations for sections.
2. Wrap sections in div, with page break before each (except first).
3. Add ability to specify generic fallback font for html (documentation change).
4. Add ability to specify handling of whitespace in html (documentation change).
   Currently, Word writer preserves space but HTML writer does not.
5. Support for Language, both for document overall and individual text elements.
6. Support for PageBreak for HTML (currently only PDF is supported).
7. Support for Table Border style, color, and size.
8. Support for empty paragraphs (Word writer permits, browsers generally suppress).
9. Default paragraph style should apply to all paragraphs, as well as class Normal.
10. Paragraph style should support line-height.
11. Paragraph style should support indentation.
12. Paragraph style should support page-break-before.
13. Paragraph style should not specify margin-top/bottom when spacing is null.
@oleibman oleibman deleted the htmlchanges_rebased branch December 13, 2023 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant