Forum


Replies: 7   Views: 981
Add pagination and contents to the footers replacing them in an existing docx
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 Diplodoc071  · 24-12-2021 - 09:23

All my code now:

$phpdocx=new CreateDocxFromTemplate(ROOT_DIR.UPLOAD_DOCUMENTS_DIR.$document_source);
$phpdocx->importHeadersAndFooters(ROOT_DIR.UPLOAD_DOCUMENTS_DIR.$document_source);
$phpdocx->removeWordContent(array('type'=>'break'));
$content=new WordFragment($phpdocx,'document');
$content->addText('');
$phpdocx->replaceWordContent($content,array('type'=>'break'));
$phpdocx->removeHeaders();
$phpdocx->removeFooters();
$phpdocx->addBreak(array('type'=>'page'));
$phpdocx->embedHTML($add_text);
$numbering=new WordFragment($phpdocx,'defaultFooter');
$numbering->addPageNumber('numerical',array(
        'textAlign'=>'right',
        'bold'=>true,
        'sz'=>14,
        'color'=>'65a9ef',
));
$numbering->embedHTML($footer_html);
$phpdocx->addFooter(array('default'=>$numbering,'first'=>$numbering,'even'=>$numbering));
$phpdocx->createDocx(ROOT_DIR.UPLOAD_DOCUMENTS_DIR.$temp_name);
$phpdocx->transformDocument(ROOT_DIR.UPLOAD_DOCUMENTS_DIR.$temp_name,ROOT_DIR.UPLOAD_DOCUMENTS_DIR.$pdf_name);
$pdf_util=new PdfUtilities();
$pdf_util->addBackgroundImage(ROOT_DIR.UPLOAD_DOCUMENTS_DIR.$pdf_name,ROOT_DIR.UPLOAD_DOCUMENTS_DIR.$pdf_name,ROOT_DIR.IMAGES_SETTINGS_DIR.$settings['wtm'],array('height'=>'auto','width'=>'auto','opacity'=>0.1));