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

HTML text-align style not working when using addHtml() #2115

Closed
BrainforgeUK opened this issue Jul 16, 2021 · 3 comments
Closed

HTML text-align style not working when using addHtml() #2115

BrainforgeUK opened this issue Jul 16, 2021 · 3 comments

Comments

@BrainforgeUK
Copy link

BrainforgeUK commented Jul 16, 2021

Describe the Bug

HTML text-align style not working.

Steps to Reproduce

PHP
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html);

header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment;filename="test.docx"');

$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('php:https://output');

HTML
<h1 style="line-height: 23px;text-align: center;font-size: 20px;">Chapter 27</h1>

Expected Behavior

Text to be centred.
Also text-align:right no recognised.

Current Behavior

Text is left aligned

Context

@BrainforgeUK
Copy link
Author

Found this does not work either - no indentation or italic text
... am I doing something wrong?

<p style="padding-left: 50px;padding-right: 50px;font-style: italic;">' . trim($matches[1]) . '</p>

Using these did not work either <center> and <i>

BUT found <sup style="vertical-align: super;"sup>ABCsup</sup> worked
While <span style="vertical-align: super;">ABC</span> did not work.

@BrainforgeUK
Copy link
Author

For text-align in h1 tags use a p tag instead.
Not ideal as that breaks the link to style Header 1.

@OussamaKhoubran
Copy link

Any news about this issue, the alignment is not applied on all the heading!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants