PHPWord
PHPWord copied to clipboard
setValue-> blank space at end of string gets stripped
Hi,
I'm currently bound to version 0.6.2. Working with my Template-docx, I'm replacing values successfully via setValue(), BUT: When I try to add a comma followed by a blank space as string (', '), the blank space always gets stripped if being at the end of a string. That's really annoying, because I need that space, I cant set it fix in the Template, because it's in a variable position.
Bug ? Feature ? Ideas to fix this problem ?
I'm not doing things like rtrim before setValue, so this seems to be a problem of PHPWord (0.6.2).
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
try this: $templateProcessor->setValue('UPPER', '<w:t xml:space="preserve"> 0</w:t>');
It's not working
Could you please send me your PHP-file and Word template? I have just checked out my example and it worked for me.
2017-04-04 13:38 GMT+03:00 Dimitar Zlatev [email protected]:
It's not working
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PHPOffice/PHPWord/issues/637#issuecomment-291462009, or mute the thread https://github.com/notifications/unsubscribe-auth/AChVgkq3Hyl_H0ix8XMaTI7gaHQJ7SP7ks5rsh2ngaJpZM4GPf_- .
-- С уважением,
Дмитрий Степанов +7 903 190-50-28
Sorry, in my case it doesn't work because I have Output Escaping turned on:
\PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true);
anybody found solution of it?
In my case I'm overriding the following method:
protected function setValueForPart($search, $replace, $documentPartXML, $limit)
{
$replace = preg_replace('/\\\n/', '<w:br/>', $replace); // replace \n with 'newline'
$replace = preg_replace('/\\\s/', '<w:t xml:space="preserve"> </w:t>', $replace); // replace \s with 'space'
return parent::setValueForPart($search, $replace, $documentPartXML, $limit);
}
In my language strings I use \n
and \s
instead of 'newline character' and 'space'
$replace = preg_replace("/\\\s/", '<w:t xml:space="preserve"> </w:t>', $replace);
whitespaces