0

I am tryinng to Create simple phpword file into pdf but haven't any idea how to approach i read many documentation and examples but all are bit confusable please help if possible -

You can suggest any example in phpspreasheet also

Code

    <?php
use PhpOffice\PhpWord\SimpleType\VerticalJc;

include_once 'Sample_Header.php';

// New Word Document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();

// New portrait section
$section = $phpWord->addSection(array('borderColor' => '00FF00', 'borderSize' => 12));
$section->addText('I am placed on a default section.');

// New landscape section
$section = $phpWord->addSection(array('orientation' => 'landscape'));
$section->addText('I am placed on a landscape section. Every page starting from this section will be landscape style.');
$section->addPageBreak();
$section->addPageBreak();

// New portrait section
$section = $phpWord->addSection(
    array('paperSize' => 'Folio', 'marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600)
);
$section->addText('This section uses other margins with folio papersize.');

// The text of this section is vertically centered
$section = $phpWord->addSection(
    array('vAlign' => VerticalJc::CENTER)
);
$section->addText('This section is vertically centered.');

// New portrait section with Header & Footer
$section = $phpWord->addSection(
    array(
        'marginLeft'   => 200,
        'marginRight'  => 200,
        'marginTop'    => 200,
        'marginBottom' => 200,
        'headerHeight' => 50,
        'footerHeight' => 50,
    )
);
$section->addText('This section and we play with header/footer height.');
$section->addHeader()->addText('Header');
$section->addFooter()->addText('Footer');

// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
    include_once 'Sample_Footer.php';
} 
  • 3
    Please go read [ask]. We are not here to research code examples for you, that is something you can do on your own. If you want our help here, then you need to give us a proper problem description first of all. If you are confused about anything in particular - then explain what _exactly_ that is. – misorude Feb 13 '20 at 12:42
  • https://stackoverflow.com/questions/33084148/generate-pdf-from-docx-generated-by-phpword – Premlatha Feb 14 '20 at 01:02

0 Answers0