Forum


Replies: 9   Views: 4140
Upgrade from 3.7 to 4.0 : issues
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 Bluecoat Systems  · 11-07-2014 - 14:50

Hi, so I have started my migration from 3 to 4 and just need to clarify some things. is the following the correct method, it is working but it seems a lot more work to create a new WordFragment for each line of text, especilay when a lot of my code creates lots of tables with images and text in. // Default Footer. $footerLayout = new WordFragment($docx, 'defaultFooter'); $col1 = new WordFragment($docx); $col1->addDateAndHour( array('jc' => 'left', 'b' => 'on', 'sz' => 7, 'color' => '555555', 'dateFormat' => "dd' of 'MMMM' 'yyyy' at 'H:mm" ) ); $col2 = new WordFragment($docx); $col3->addPageNumber('numerical', array('jc' => 'center', 'b' => 'on', 'sz' => 7, 'color' => '555555' ) ); $col3 = new WordFragment($docx); $col3->addtext('Company Name', array('jc' => 'right', 'b' => 'on', 'sz' => 7, 'color' => '555555' ) ); $footerLayout->addTable( array( array( $col1, $col2, $col3 ) ) ), array( 'border' => 'none', 'jc' => 'center', 'tableWidth' => array( 'type' => 'pct', 'value' => 100 ) ) ); $docx->addFooter(array('default' => $footerLayout)); The other thing that does not seem to be working is the template header. There are the exact same lines , working in 3 but not in 4. And both read the same file. The header on the 1st page never shows. $docx->importHeadersAndFooters("../Corporate_Word_Template.docx", "header"); I have to use "merge" as "replace" does not seem to work, not a problem as I get what I want anyway. $docx->importStyles("../Corporate_Word_Template.docx", "merge"); Many Thanks G.

Posted by admin  · 14-07-2014 - 07:13

Hello, Yes, you need more code lines to do complex things, but it's much more powerful than phpdocx 3.7. About importing headers please run the included example LayoutAndGeneral/importHeadersAndFooters/sample_1.php. Also check the code of this file that includes header and footer standalone import. Regards.

Posted by Bluecoat Systems  · 14-07-2014 - 10:35

Hi, thanks for the confirmation and yes it does make it a lot more powerful :) As for the header, I did test the sample and used my template document and it work fine. It just for some reason is not working on the main doc generator. Also I am finding that only one page is being generated even though there are multiple pages. Each page works when generated on a single bases, but as soon as you create multi pages only the last works. Again I have tested the sample code and it does work so I think its just a case of working through the migration process. Is there a document of the changes between version or deprecated commands. I noticed all the 'jc' are now "textAlign" and 'b' are 'bold' which makes sense as its easier to read. thanks again for a great tool, my engineers love it :) G.

Posted by Bluecoat Systems  · 14-07-2014 - 11:47

Hi, it looks like the foot injection is causing the issue I am having, I modified the sample "addSection" to the following and it only shows the 1st and last page. G. //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocx(); $text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ' . 'enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut' . 'aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit ' . 'in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ' . 'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui ' . 'officia deserunt mollit anim id est laborum.'; $docx->addText($text); $paramsText = array( 'b' => true ); $docx->addText($text, $paramsText); $docx->addSection('nextPage', 'A4'); // Default Footer. $footerLayout = new WordFragment($docx, 'defaultFooter'); $col[0] = new WordFragment($docx); $col[0]->addDateAndHour( array('textAlign' => 'left', 'bold' => true, 'fontSize' => 7, 'color' => '555555', 'dateFormat' => "dd' of 'MMMM' 'yyyy' at 'H:mm" ) ); $col[1] = new WordFragment($docx); $col[1]->addPageNumber('numerical', array('textAlign' => 'center', 'bold' => true, 'fontSize' => 7, 'color' => '555555' ) ); $col[2] = new WordFragment($docx); $col[2]->addtext('My Company name', array('textAlign' => 'right', 'bold' => true, 'fontSize' => 7, 'color' => '555555' ) ); $footerLayout->addTable( array( $col ), array( 'border' => 'none', 'textAlign' => 'center', 'tableWidth' => array( 'type' => 'pct', 'value' => 100 ) ) ); $docx->addFooter(array('default' => $footerLayout)); $docx->addText($text); $docx->addSection('nextPage', 'A4-landscape'); $docx->addText($text); $docx->addSection('nextPage', 'A4'); $paramsText = array( 'b' => true ); $docx->addText($text, $paramsText); $docx->createDocx('example_addSection_1');

Posted by admin  · 15-07-2014 - 14:58

Hello, We're checking the issue. Regards.

Posted by admin  · 16-07-2014 - 10:50

Indeed there was a bug when one added a section a footer and another section. We already patched it and wewillintegarte it in v4.1 In the meantime we will send you the patch to your registered email.

Posted by Bluecoat Systems  · 16-07-2014 - 11:07

Hi, many thanks for the patch works a treat. G

Posted by meesmany  · 16-10-2014 - 14:18

Hello, I've got the same problem and i'm stuck with it. could you please send me the patch for this issue. Thank you.

Posted by admin  · 17-10-2014 - 07:41

Hello, That patch was integrated in phpdocx 4.0 and phpdocx 4.1, so you just need to download the package froum your account. Regards.

Posted by meesmany  · 17-10-2014 - 16:09

Hello, OK. many thanks for the team.