This project is read-only.

convert margin-left or margin-right properly

May 31, 2012 at 10:27 AM

Hi guys

first of all! well done and good job for this project!

i have problem when i try to convert

<p style="margin-left: 300px"> test hello world</p>

to docx

However, there is not any spacer. it seams that css property margin does not work properly.

could any one provide some example?



Jun 7, 2012 at 7:06 PM

Hi yee

In the HTML to docx converter we use PHPWord text runs containing text elements to create separate paragraphs (defined by <p> tags in HTML), you cannot assign a margin left or margin right property to these (see the PHPWord documentation). You can however assign a margin to a whole block of HTML you convert - see line 17 of example.php:

$section = $phpword_object->createSection();

You can add a margin to this section before adding in your HTML, for example:

$sectionStyle = array('marginLeft' => 300);
$section = $phpword_object->createSection($sectionStyle);
See page 5 of the PHPWord documentation for an explanation of this.