Forum


Replies: 3   Views: 1099
Set first page of document to be its own section
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 meverett  · 03-09-2021 - 13:30

I am using embedHTML to generate the document. My issue is I would like to apply a special page layout to only the first page, but I can't figure out how to make the first page its own section when the content is dynamically generated. Is there a way to add a section break at the end of the first page by default?

Posted by admin  · 03-09-2021 - 14:20

Hello,

What version and license of phpdocx are you using?

If you are creating the DOCX from scratch you can use modifyPageLayout to change the layout of the current section and addSection to create and add new sections. More complex tasks may require an Advanced or a Premium license.

Regards.

Posted by meverett  · 03-09-2021 - 14:46

I am currently using the trial version while I test things out. The issue with using addSection is I would need to call it after I embed the HTML, but that would create a section at the end of all the HTML content when I need it to be after the first page. The other issue is that the content being generated in the HTML can be any length because each source has unique content. 

Is there a way to do this in the premium or advanced licenses?

Posted by admin  · 03-09-2021 - 16:06

Hello,

Yes, for that specific task you need to use an Advanced or a Premium that allow adding contents in specific positions using DOCXPath or, maybe an easier approach, using mergeDocx to generate a DOCX and add a first page before it. We recommend you using a Premium license so you can also use DOCXCustomizer (among all other features of this license) that will ease your code.

Please note that, internally, DOCX documents don't work with pages but with sections. A section can fill one page or more pages (or even less than a page).

After you have purchased a license, do not hesitate to contact us on contact[at]phpdocx.com with a DOCX sample that illustrates exactly the output you need to get and we'll generate a sample code using phpdocx.

Regards.