phpdocx

page break not working in phpdocx library


I am using PHPDocx library.Basically I'm having an issue with page-break Here is my code

    $html_body .= 'Lorem Ipsum is simply dummy text of the printing and typesetting industry';$html_body .= 'Lorem Ipsum is simply dummy text of the printing and typesetting industry';

i just want to break page so that both the paragraph appear on different page. Please help me out. Thanks


Solution

  • If you are using embedHTML() method the only way you can achieve this, is separating you html code, and adding an use addBreak() method between. Something like this:

    require_once '../../../classes/CreateDocx.inc';
    
    $docx = new CreateDocx();
    
    $paragraph1 = '<p>Lorem Ipsum is simply dummy text of the printing and type setting industry</p>';
    $paragraph2 = '</br><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>';
    
    $docx->embedHTML($paragraph1);
    
    $docx->addBreak(array('type' => 'page'));
    
    $docx->embedHTML($paragraph2);
    
    $docx->createDocx('example_embedHTML_1');