Forum


Replies: 4   Views: 4993
Extra white space before first line.
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by jordyboytjuh  · 04-02-2015 - 09:24

I've a problem with my spaces. I've declared my managementsummary as variable in my template. When I'm replacing it by html, on my first line there is a space before the first word. There is a space on each new row. When a row goes to the end of the page, and automatically to the second row, everything is fine. With replaceVariableByText() is the row fine, there is no space visible. My replace code: $docx->replaceVariableByHtml('MANAGEMENTSUMMARY', 'inline', $contentManagementSum, array('strictWordStyles'=>true)); Does that replace put an extra space before the first line? How can I prevent that? I've used the "strictWordStyles" to prevent the html changing the font-size from 10 to 12.

Posted by admin  · 04-02-2015 - 10:10

Hello, Please post or send to contact@phpdocx.com the template you're using and the HTML. Regards.

Posted by admin  · 04-02-2015 - 11:22

Hello, After checking the script and template, we see this as HTML: $contentManagementSum = 'Quisque pretium.
Testing the second row.'; The embedHtml needs that the strings are surrounded by HTML tags; the HTML must be correct. So you just need to add a new tag, for example: $contentManagementSum = '

Quisque pretium.
Testing the second row.

'; Regards.

Posted by nicks  · 12-11-2015 - 13:08

Hi,

 

I am having a very similar issue. Using output from ckeditor, it generates HTML such as:

 

<p>Test Line 1<br />
<br />
Test Line 2</p>

 

Is this ckeditor not following HTML correctly or PHPDOCX not rendering it properly on generation?

 

Thanks

Posted by nicks  · 12-11-2015 - 13:32

Managed to suss this, so for anyone else having issues you need to strip any newlines or tabs from the output generated from ckeditor.

 

This worked for me:

 

$string = str_replace(array("\n", "\t", "\r"), '', $string);