Difference with Word 2011 (MAC) and Word 2010 (PC) --> Linebreak?

Feb 6, 2013 at 7:04 AM
Hi guys,

I use PHPword within a new client application, this to print invoices. I develop on a mac and using Office 2011 for Mac. Works perfectly, nice clean document. But if I print the same document in Office 2010 on PC, it's totally different. It adds an extra space between every line I add, using the AddText function.
<?
$section->addText('Factuurnummer: '.$invoicenumber, array('bold'=>false, 'italic'=>false, 'size'=>8 , 'spaceAfter' => 0, 'spacing' => 0));

$section->addText('Ordernummer: '.$invoicedetails->ordernumber, array('bold'=>false, 'italic'=>false, 'size'=>8 , 'spaceAfter' => 0, 'spacing' => 0));
?>
In Office 2011 it shows what I need:

Factuurnummer: 12345
Ordernummer: 12345

If Office 2010 it shows:

Factuurnummer: 12345

Ordernummer: 12345


I have tried to add spaceAfter after reading one of the discussions, but no luck. Any ideas what it can be? Is it a PhpWord thing, or a setting in word perhaps?

Hope someone can help me! Thanks.

Robbert
Feb 11, 2013 at 3:30 AM
Edited Feb 11, 2013 at 10:28 PM
Hello WeeRab,

I encounter exactly the same problem, in Word 2008 for Mac everything ok, in Windows Word 2010 version 14.0.6129.5100 (32 bits) this problem occurs. It appears, but I must be confirmed about that, that older Windows Word versions do not show the problem. This leads to the thought that it is something in Word causing it.
[later edit: Windows Word 2007 also goes wrong.]

There is some recognition with problems in e-mail with \r versus \n, or better, using both causing extra linefeeds in some e-mailclients.. but this is different. It also strikes me that this obvious issue is not often mentioned in this board.

I searched the PHPWord source code files to find the spot where line ends are defined but not yet found. Also I had the thought that using textRun instead of addText may clear the issue. My encounter with PHPWord is only 3 days old, must experiment with textRun yet.

For the moment "heb ik nog geen idee".. I really don't know.

Also I wonder if this great product, I have respect for the builders who did their job in beautiful object orientated php, is still supported.

If I find something I will keep you informed.
Harry
Aug 22, 2013 at 12:55 PM
Hello,

here we had the same problems. Do you have a solution?

https://phpword.codeplex.com/discussions/361377

https://phpword.codeplex.com/discussions/454183

Greetz
Dec 13, 2014 at 5:43 AM
Edited Dec 13, 2014 at 5:46 AM
Hi,

a little bit late, but I faced this problem yesterday (and as I still didn't find a solution on the internet...).
It seemed, that on Word for Windows and Word for Mac OS there are different default settings for the space after a paragraph.
Even if I specified them while adding some text it didn't work for me.

The solution for me was to set the general 'spaceAfter' of a paragraph to some value:

$PHPWord->setDefaultParagraphStyle(array("spaceAfter"=>20.0*8,"spaceBefore"=>0, "lineHeight"=>1.084));

8Pt spaceAfter and 1,08 lineheight on both Word 2013 Windows and Word 2011 Mac OS.

Best regards
Florian