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

using TemplateProcessor with new line breaks justified formatting #1358

Open
2 tasks
Zxurian opened this issue Apr 25, 2018 · 0 comments
Open
2 tasks

using TemplateProcessor with new line breaks justified formatting #1358

Zxurian opened this issue Apr 25, 2018 · 0 comments

Comments

@Zxurian
Copy link

Zxurian commented Apr 25, 2018

This is:

Expected Behavior

Using the $template->setValue('AFTRA', htmlspecialchars("\nmyNewText") format to replace text in a table cell within a Word 2017 Template.
Template:
img
It should insert the text on the next new line, preserving existing formatting. so that it ends up like the following:
correct

Current Behavior

In the resulting screenshot, you can see that while it put the new text on the next line, the justification of the previous line is distored.
wrong formatting

Failure Information

Looking at the actual document.xml, it appears there is a discrepancy between what the Template Processor produces, and how Word itself handles line breaks.

Bad, Distorted Formatting

...
hour</w:t>
</w:r>
<w:bookmarkStart w:id="0" w:name="_GoBack"/>
<w:bookmarkEnd w:id="0"/>
<w:r w:rsidR="004A675A">
  <w:rPr>
    <w:rStyle w:val="PlaceholderText"/>
    <w:rFonts w:ascii="Open Sans" w:hAnsi="Open Sans" w:cs="Open Sans"/>
    <w:color w:val="auto"/>
    <w:sz w:val="20"/>
    <w:szCs w:val="20"/>
  </w:rPr>
  <w:t>
(SAG-AFTRA
...

Correct formatting

...
    hour</w:t>
  </w:r>
</w:p>
<w:p w14:paraId="627A8996" w14:textId="174F4F5E" w:rsidR="00946558" w:rsidRPr="00E1355E" w:rsidRDefault="004A675A" w:rsidP="00EE6A00">
  <w:pPr>
    <w:jc w:val="both"/>
    <w:rPr>
      <w:rFonts w:ascii="Open Sans" w:hAnsi="Open Sans" w:cs="Open Sans"/>
      <w:sz w:val="20"/>
      <w:szCs w:val="20"/>
    </w:rPr>
  </w:pPr>
  <w:r>
    <w:rPr>
      <w:rStyle w:val="PlaceholderText"/>
      <w:rFonts w:ascii="Open Sans" w:hAnsi="Open Sans" w:cs="Open Sans"/>
      <w:color w:val="auto"/>
      <w:sz w:val="20"/>
      <w:szCs w:val="20"/>
    </w:rPr>
    <w:t>(SAG-AFTRA
...

How to Reproduce

Create a template with a table inside the document, add two template variables back to back as shown in above example. Replace first variable with text, replace second variable with a line break followed by more text.

Context

  • PHP version: 7.2
  • PHPWord version: v0.14.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant