PHP Classes

File: examples/base.php

Recommend this page to a friend!
  Classes of Raskin Veniamin   VS PHP Word HTML   examples/base.php   Download  
File: examples/base.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,396 bytes
 

Contents

Class file image Download
<?php
/**
* A simple example of creating a document.
* In the document added header and added two paragraphs.
*/

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

$doc = new VsWord();
$body = $doc->getDocument()->getBody();

$title = new PCompositeNode();
$rTitle = new RCompositeNode();
$title->addNode($rTitle);
$rTitle->addTextStyle(new BoldStyleNode());
$rTitle->addTextStyle(new FontSizeStyleNode(36));
$rTitle->addText("Header 1");
$body->addNode( $title );

$paragraph = new PCompositeNode();
$rParagraph= new RCompositeNode();
$paragraph->addNode($rParagraph);
$rParagraph->addTextStyle(new FontSizeStyleNode(14));
$rParagraph->addText("Some more text ... More text about... Some more text ... More text about... Some more text ... More text about...");
$body->addNode( $paragraph );

$paragraph2 = new PCompositeNode();
$rParagraph2 = new RCompositeNode();
$paragraph2->addNode($rParagraph2);
$rParagraph2->addTextStyle(new FontSizeStyleNode(14));
$rParagraph2->addText("Some more text ... More text about... Some more text ... More text about... Some more text ... More text about...");
 

$rParagraph3 = new RCompositeNode();
$paragraph2->addNode($rParagraph3);
$rParagraph3->addTextStyle(new FontSizeStyleNode(11));
$rParagraph3->addTextStyle(new ItalicStyleNode());
$rParagraph3->addText('Italic text');

$body->addNode( $paragraph2 );
 

$doc->saveAs('./base.docx');