Register Lost your password?
Full api documentation: full api documentation FREE version full api documentation PRO version

public function createDocx(string title = ‘document’, array paramsDocument = array())

Parameters

title

  • filename of the document



$paramsDocument

  • ‘orient’ (page orientation) :’landscape’
  • ‘top’ (top margin) : 4000,..
  • ‘bottom’ (bottom margin) : 4000,..
  • ‘right’ (right margin) : 4000,..
  • ‘left’ (left margin): 4000,..
  • ‘titlePage’ (if the first page contains the header): 1

Examples

Example 1


require_once 'classes/CreateDocx.inc';

$docx = new CreateDocx();

$text = 'Lorem ipsum dolor sit amet.';

$docx->addText($text, $paramsText);

$docx->createDocx('example_text');

    8 Responses

  • Greg

    You need to do some major rewriting for php 5.3 as the word NAMESPACE is reserved. I would also recommend using a naming convention similar to how the Zend Framework is set up so that you do not need to declare your own autoloader.

  • Greg

    Also, lines 19, 21, and 22 of cCreateDocx.inc declare variables that are either not used or improperly named.

    private $intIdWords;
    - should be
    private $intIdWord;

    private $xml_ContentTypes__Content;
    - should be
    private $xml_ContentType__Content;

    You should set up a public forum for people like me to post these issues.

  • Ian

    I’m currently installing phpdocx files.
    I tried to run the file Documents_font.php in the examples folder. It simply returns error.

    Can’t find the echo that spits out this Error. To see where I have gone wrong.

    Can you point me in the right direction?

  • letux

    you have an error in you doc:

    $arrParamsDocument = array(’orient’ => ‘landscape’,'top’ => 4000, ‘bottom’ => 4000, ‘right’ => 4000; ‘left’ => 4000, ‘titlePage’ => 1);

    should be (=>4000;)

    $arrParamsDocument = array(’orient’ => ‘landscape’,'top’ => 4000, ‘bottom’ => 4000, ‘right’ => 4000, ‘left’ => 4000, ‘titlePage’ => 1);

  • jolyon2000

    I have the same problem as Ian - how do i know what to do if it simly spills out ‘Error’ ?

  • jolyon2000

    If i run the code in your example, where is it likely to output the resulting docx file - in the same directory as cCreateDocx.inc ? If so, doesn’t the class directory need to be writable?

    Also, is there a way to specify a path where documents can be output to ?

  • Carlos Valencia

    How can i get different margins on page two??? that i want to know is if i can have different margins in the same document

  • Jon

    @jolyon2000
    You should be able to specify the path like this:
    $docx->createDocx(’/somefolder/example_page’, $paramsPage);
    Assuming that your web server can write to that directory.

Your comments