Quantcast
Channel: PHPWord
Viewing all articles
Browse latest Browse all 450

New Post: Create a text with a newspaper style (sample 05 is not working)?

$
0
0
I'm Trying use the sample 05 on phpword to create a text with Multi Columns (like a newspaper).

The sample here:

https://github.com/PHPOffice/PHPWord/blob/develop/samples/Sample_05_Multicolumn.php#L1

But using the sample 05 is not working, an error appears saying

"Call to a member function addSection() on null"

Can somebody give me a another example to how to do this?


This is my code:

require_once 'PHPWord.php';
 // New Word Document
 $PHPWord = new PHPWord();

 // New portrait section
  $section = $PHPWord->createSection();



 // Two columns text
     $section = $phpWord->addSection(
         array(
        'colsNum'   => 2,
        'colsSpace' => 1440,
        'breakType' => 'continuous',
      )
);


$section->addText(htmlspecialchars("Two columns, one inch (1440 twips) spacing.", ENT_COMPAT, 'UTF-8'));




// Save File
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('AdvancedTable.docx');

Thanks.

Viewing all articles
Browse latest Browse all 450

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>