PHP Classes

File: examples/align.php

Recommend this page to a friend!
  Classes of Raskin Veniamin   VS PHP Word HTML   examples/align.php   Download  
File: examples/align.php
Role: Example script
Content type: text/plain
Description: Example script
Class: VS PHP Word HTML
Create DOCX Word document dynamically from HTML
Author: By
Last change:
Date: 9 years ago
Size: 1,410 bytes
 

Contents

Class file image Download
<?php

/*
 * Example text alignment.
 */

require_once '../vsword/VsWord.php';
VsWord::autoLoad();

$doc = new VsWord();

$paragraph = new PCompositeNode();
$paragraph->addPNodeStyle( new AlignNode(AlignNode::TYPE_RIGHT) );
$paragraph->addText("Some more text ... More text about... Some more text ... More text about... Some more text ... More text about...");
$doc->getDocument()->getBody()->addNode( $paragraph );

$paragraph = new PCompositeNode();
$paragraph->addPNodeStyle( new AlignNode(AlignNode::TYPE_LEFT) );
$paragraph->addText("Some more text ... More text about... Some more text ... More text about... Some more text ... More text about...");
$doc->getDocument()->getBody()->addNode( $paragraph );

$paragraph = new PCompositeNode();
$paragraph->addPNodeStyle( new AlignNode(AlignNode::TYPE_CENTER) );
$paragraph->addText("Some more text ... More text about... Some more text ... More text about... Some more text ... More text about...");
$doc->getDocument()->getBody()->addNode( $paragraph );

$paragraph = new PCompositeNode();
$paragraph->addPNodeStyle( new AlignNode(AlignNode::TYPE_BOTH) );
$paragraph->addText("Some more text ... More text about... Some more text ... More text about... Some more text ... More text about...");
$doc->getDocument()->getBody()->addNode( $paragraph );
/**/
echo '<pre>'.($doc->getDocument()->getBody()->look()).'</pre>';

$doc->saveAs('align.docx');