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

Bug while transforming html to word document with addHtml method. #2467

Closed
StepanKutyrev opened this issue Sep 12, 2023 · 0 comments · Fixed by #2475
Closed

Bug while transforming html to word document with addHtml method. #2467

StepanKutyrev opened this issue Sep 12, 2023 · 0 comments · Fixed by #2475
Milestone

Comments

@StepanKutyrev
Copy link

StepanKutyrev commented Sep 12, 2023

Describe the Bug

There is a bug in the phpword while transforming HTML to a Word document and it doesn’t recognize text-align: right. So we need to edit this file vendor/phpoffice/phpword/src/PhpWord/SimpleType/Jc.php and set const END = 'right'; instead of const END = 'end'; before running the transforming process.

Steps to Reproduce

Here is an example of HTML code :

<p style="text-align:justify;"><strong>Poursuivre la gestion sur un compte dédié.</strong></p>
<p style="text-align:right;"><strong>Poursuivre la gestion sur un compte dédié.</strong></p>
<p style="text-align:right;">Frais de gestion de <strong>xx euros / mois HT</strong> facturés par Auto-planning.</p>

And php code:

$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $ourHtmlCode, false, false);
$docFileName = "docFileNaame";
$objWriter   = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord);
$objWriter->save('/somePath/'. $docFileName);
$localDocFilePath = $tempPath . $docFileName;
$docContent       = $this->apiStorage->read($localDocFilePath);
$this->apiStorage->delete($localDocFilePath);
return $this->googleDriveStorage->write(
          'googleDiskFolderId',
          $docContent,
          [
               'name'     => $docFileName,
               'mimeType' => 'application/vnd.google-apps.document'
          ]
);

Current Behavior

When I transform HTML code with align right to word doc. I do not have alignment in that place (For other align it works well)

Context

  • PHP Version: 7.2
  • PHPWord Version: dev-master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants