Forum


Replies: 13   Views: 3495
Add section and change page orientation with htmlextended
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 admin  · 24-05-2019 - 06:46

Hello,

You need to set custom margins if you don't want to use the default values of the chosen paper type when creating sections using addSection (phpdocx_section tag):

<phpdocx_section data-paperType="A4-landscape" data-sectionType="nextPage" data-marginTop="850" data-marginRight="1077" data-marginBottom="850" data-marginLeft="1077" />

About your other question, because of how sections work you only can generate one section for each embedHTML method call, for example:

$html = '
    <phpdocx_modifypagelayout data-paperType="A4" data-marginTop="850" data-marginRight="1077" data-marginBottom="850" data-marginLeft="1077" />

    <p>Paragraph 1</p>
    <p>Paragraph 2</p>
';
$docx->embedHTML($html, array('useHTMLExtended' => true));
$html = '
    <phpdocx_section data-paperType="A4-landscape" data-sectionType="nextPage" data-marginTop="850" data-marginRight="1077" data-marginBottom="850" data-marginLeft="1077" />

    <p>Paragraph A</p>
    <p>Paragraph B</p>
';
$docx->embedHTML($html, array('useHTMLExtended' => true));
$html = '
    <phpdocx_section data-paperType="A4" data-sectionType="nextPage" data-marginTop="850" data-marginRight="1077" data-marginBottom="850" data-marginLeft="1077" />

    <p>Paragraph I</p>
    <p>Paragraph II</p>';
$docx->embedHTML($html, array('useHTMLExtended' => true));
$html = '
    <phpdocx_section data-paperType="A4-landscape" data-sectionType="nextPage" data-marginTop="850" data-marginRight="1077" data-marginBottom="850" data-marginLeft="1077" />

    <p>Paragraph a</p>
    <p>Paragraph b</p>
';
$docx->embedHTML($html, array('useHTMLExtended' => true));

We have moved a request to add support to generating multiple sections in the same embedHTML method to the dev team.

Regards.