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

TemplateProcessor Distorting Tables #2689

Open
2 tasks
DPineault opened this issue Oct 10, 2024 · 1 comment
Open
2 tasks

TemplateProcessor Distorting Tables #2689

DPineault opened this issue Oct 10, 2024 · 1 comment

Comments

@DPineault
Copy link

DPineault commented Oct 10, 2024

Describe the bug and add attachments

I'm simply opening a docx, replacing a value and saving the resulting file, but the file which was 1 page now is returned over 4 and the table in which the variable was found is huge, out of bounds... So the formatting of the table as get changed even though I have done nothing to do so.

Expected behavior

The document formatting retains the original dimension and only the variable is edited.

Steps to reproduce

$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($sFile);
$templateProcessor->setValue('var1', 'test');
$fileName = $templateProcessor->save();
$phpWordObject = \PhpOffice\PhpWord\IOFactory::load($fileName);
$writer = \PhpOffice\PhpWord\IOFactory::createWriter($phpWordObject, 'Word2007');
$writer->save('php://output');

$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($sFile);
$templateProcessor->setValue('var1', 'test');
$tmpFile = 'SomePathAndFileName.docx';
$templateProcessor->saveAs($tmpFile);
$phpWordObject = \PhpOffice\PhpWord\IOFactory::load($tmpFile);
$writer = \PhpOffice\PhpWord\IOFactory::createWriter($phpWordObject, 'Word2007');
$writer->save('php://output');

In the above instance I verified the $tmpFile and it is correct, but when I use the writer to output the file for download, it is all off.

PHPWord version(s) where the bug happened

1.3

PHP version(s) where the bug happened

7.4

Priority

  • I want to crowdfund the bug fix (with @algora-io) and fund a community developer.
  • I want to pay the bug fix and fund a maintainer for that. (Contact @Progi1984)
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
@DPineault and others