Forum


Replies: 10   Views: 978
Import footer from template but keep the serial number/page number
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 usman12  · 06-05-2022 - 10:46

Hi, 

I am using phpdocx to import the footer using CreateDocxFromTemplate method which works well but I have a special condition, I have a serial number in the center of the footer with the page number. I don't want to remove that part when importing the footer. Is this possible? 

To understand it clearly please see the screenshot here: https://ibb.co/QY08HsP

 

Posted by admin  · 06-05-2022 - 10:57

Hello,

What version and license of phpdocx are you using? If you are using a purchased license please send to contact[at]phpdocx.com the email or username of the user that purchased the license.

phpdocx doesn't remove contents using the CreateDocxFromTemplate class unless specific methods to remove elements are called. The content of some fields (such as fldSimple tags), for example page numberings, are handled by MS Word and other DOCX readers automatically.

Regards.

Posted by usman12  · 06-05-2022 - 11:52

Thanks for your quick response.

Still, we are using the trial version to test if it fits our needs before purchasing It and it is working well but only this issue which I explained. 

This is the code sample that I am using to import the footer from the existing file.

Please see and advise me if I am doing something wrong?

//import_footer_into.docx file exist in the directory with other contents
$docx = new CreateDocxFromTemplate('import_footer_into.docx');
//import_footer_from.docx file exist in the directory with footer
$docx->importHeadersAndFooters('import_footer_from.docx', 'footer');
$docx->createDocx('import_footer_into.docx');

 

Posted by admin  · 06-05-2022 - 12:27

Hello,

To accomplish the requested task (import specific contents and keep existing contents in headers/footers) you need to use DOCXPath available only in Advanced and Premium licenses. The trial package doesn't include this feature.

After purchasing an Advanced or a Premium license please send your DOCX documents to contact[phpdocx].com and we'll generate a sample script using them.

Regards.

Posted by usman12  · 06-05-2022 - 13:02

"After purchasing an Advanced or a Premium license please send your DOCX documents to contact[phpdocx].com and we'll generate a sample script using them."

Just want to make sure you understand correctly that we have a lot of files and every time we will have different files in which footer content will be imported and keep the serial/page number unchanged in every file.

Please confirm so we can move forward to purchase the license and send it to you?

Thanks

Posted by admin  · 06-05-2022 - 13:15

Hello,

After purchasing an Advanced or a Premium license, please send two sample DOCX documents (one to be used as template and another with the headers/footers to be imported), and we'll generate a sample script using DOCXPath to illustrate how to do the requested task. You'll be able to use this sample script to generate other scripts if needed; of course the serial/page content to be imported must have something to be queried by (position, content, format, ID or any other property as DOCXPath requires; on https://www.phpdocx.com/documentation/introduction/docxpath you can undestand how DOCXPath works).

Regards.

Posted by usman12  · 06-05-2022 - 15:00

Hello,

I have read the DOCXPath and here is my question 

1- if we have 500+ files and each file with a different footer and we want to import the footer into each file from the template using loop then the same script will work for each file? Because each file has a different footer.

2-When I imported the footer using the Trial version it destroyed the format. We will not face the format issue with the Advanced or Premium license? Please see the following image to understand better what happen when I tried to use the Trial Version.

Footer to import: https://ibb.co/GJRtVtv

Imported footer: https://ibb.co/kxZSkQq

Thanks

Posted by admin  · 06-05-2022 - 18:08

Hello,

The serial/page content to be imported or kept must have something to be queried by (position, content, format, ID or any other property as DOCXPath requires). If you want to automatize it you need to be able to query it correctly to don't get other unwanted contents.

The importHeadersAndFooters method import contents (and inline styles) not external styles. If the contents to be imported include external styles that are not avaiable in the template then you need to create them to get the same output, otherwise the default styles from the template will be used.

Regards.

Posted by usman12  · 09-05-2022 - 18:12

Hello,

Thank you for providing me with all the details. I am a developer and I have talked to my client and he is ready to buy the license but before that, we need to test the premium features. Can you please provide me the link where the premium license is being used so I can test some of the premium features there?

Thank you

Posted by admin  · 09-05-2022 - 18:59

Hello,

The trial package (https://www.phpdocx.com/download_trial) includes the features of the Basic license.

Advanced and Premium licenses don't have a trial available. We guarantee that everything will work as explained on the documentation pages.

Regards.

Posted by usman12  · 13-05-2022 - 10:44

Hello,

we have purchased the premium license and sent the details to: contact@phpdocx.com

Please see and let me know. 

Thanks & Regards