Forum


Replies: 3   Views: 3460
Each time i add word ml to a header or footer, it adds a new line too
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 seb  · 26-01-2015 - 12:36

Hiya, In phpdocx 4.5, each time I call the addWordML() function to add something to a header or footer, it also adds a new line (carriage return) to the header or footer. For example in the following code, it adds the WordML objects to the footer, but also adds 6 new lines which messes everything up: $footer = new \Phpdocx\Elements\WordFragment($this->_docx,'defaultFooter'); $footer->addWordML($fgmt_bg_image); $footer->addWordML($fgmt_by_client_logo); $footer->addWordML($fgmt_for_client_logo); $footer->addWordML($fgmt_row_1); $footer->addWordML($fgmt_row_2); $footer->addWordML($fgmt_row_3); $docx->addFooter(array('default'=>$footer)); Is there a patch I can add to your classes to stop it from adding new lines each time? Here is a download of the docx which has all these new lines (carriage returns) in the footer: http://oyster.proptest.co.uk/header_footer_example_seb.docx Thank you! Seb

Posted by admin  · 27-01-2015 - 07:58

Hello, To create complex headers or footers, we recommend you to use tables or import them from a template. You can get more info on: http://www.phpdocx.com/practical/headers-and-footers Regards.

Posted by seb  · 27-01-2015 - 09:00

Thank you for your reply, much appreciated. I've tried using a template, but it seems like you can't change the color of the text that you're trying to replace. For example I have a text box in the footer which may need to have red, blue, or black text replaced in to it. I've tried all the different replaceVariableBy... functions, but none of them let me target the footer or change the text's colour. Maybe you're able to help me on this last problem I have please?

Posted by admin  · 27-01-2015 - 15:30

Hello, Currently, phpdocx can't change the color of the text in headers/footers with the method replaceVariableByText, and the replaceVariableByHtml doesn't support replacing placeholders in headers/footers. A future version will add support. Regards, Jorge