Forum


Replies: 3   Views: 2266
How do i addfootnote without replacing the existing footnote
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 elyb  · 10-10-2017 - 06:19

Hi Im trying to addfootnote on my docx.

I can add footnote but the problem is the existing footnote (pagenumber)on my docx is replacing the new one.

I want to retain footnote (pagenumber).

this is my code


$docx = new CreateDocxFromTemplate(FCPATH.$path.$file);
$footnote = new WordFragment($docx, 'document');

$footnote->addFootnote(array(
                         'textDocument' => 'sample text',
                         'textFootnote' => 'test',
                         'footnoteMark' => array('sz' => 16,'font'=> 'Bar-Code 39', 'textAlign' => 
                                                  'right')
                             )
                         );

$docx->addFooter(array('default' => $footnote));
$docx->createDocx(FCPATH.$path.$file);

 

Posted by admin  · 10-10-2017 - 06:28

Hello,

What version and license of phpdocx are you using?

Regards.

Posted by mjeamosara  · 10-10-2017 - 06:39

Hi admin sorry ive login the wrong account.. im the one who post this..

my version is 7.0, ive recently bought the license.. basic actually.

so can I retain the footer while adding new footer?

Posted by admin  · 10-10-2017 - 07:04

Hello,

Yes, you can keep the footer content and add new contents. As you are using a template, instead of adding a footer that overwrites the existing footer, you need to set placeholders to the footer in the template and use this method to replace the placeholders by WordFragments:

https://www.phpdocx.com/api-documentation/templates/replace-variable-word-fragment-Word-document

setting the target as footer. Almost all template methods allow to set the target option, so you can replace placeholders by text, WordFragments, HTML and other contents.

Regards.