Forum


Replies: 3   Views: 776
Adding header and footer in trial version
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  · 11-07-2022 - 10:18

Hello,

addHeader and addFooter methods are available in the trial package. We recommend you to check and run the samples included in the package (examples folder), all samples are fully tested and working. Please test the samples using phpdocx standalone so you can check they are working correctly.

We have tested the following script that uses your PHP code:

$docx = new CreateDocx();
$textOptions = array(
    'fontSize' => 13,
    'b' => 'on',
    'color' => '567899',
);
$headerText = new WordFragment($docx, 'defaultHeader');
$headerText->addText('PHPDocX Header Title', $textOptions);
$docx->addHeader(array('default' => $headerText));

$docx->embedHTML('<p>HTML content</p>');

$docx->createDocx('output');

And a DOCX with a header is generated correctly. If you don't get any DOCX output please check your server logs, maybe some rw access is missing to generate the DOCX file. If the problem is that your code is not downloading the DOCX, maybe the problem comes from the code you are running to download it. On https://www.phpdocx.com/documentation/cookbook/download-generated-docx you can read the generic instructions to generate and download a DOCX, but if you are using a framework or CMS you may need to use a custom code; for example, if you are using Symfony you need to set the correct Response (https://ourcodeworld.com/articles/read/329/how-to-send-a-file-as-response-from-a-controller-in-symfony-3), or other code if you are using Laravel, Yii, Drupal...

Also note that the transformDocument method is not available in the trial package. This method is only available in Advanced and Premium licenses.

Regards.