Search code examples
phpopentbs

OpenTBS / PHP - How can I create a multipage document(docx) in OpenTBS?


Scenario

I am trying to create more than one page in OpenTBS (.docx file) from a PHP array with each array element corresponding to a page of data.

Question

How can I insert new pages for every data element?

Any help would be appreciated.

PHP Code

    foreach($actionItems as $actionItem)
    {
                array_push($data, array(
                    'ActionItemID' => $actionItemID,
                    'ActionItemTitle' => $actionItemTitle,
                    'Assignor' => $assignorLastFirst,
                    'Criticality' => $criticality,
                    'Owner' => $ownerLastFirst,
                    'AltOwner' => $altOwnerLastFirst,
                    'AssignedDate' => $assignedDate,
                    'DueDate' => $originalDueDate,
                    'ECD' => $ecd,
                    'ClosureDate' => $closureDate,
                    'Team' => $team,
                    'Department' => $department,
                    'Source' => $source,
                    'Project_Phase' =>$projectPhase,
                    'ActionItemStatement' => $actionItemStatement,
                    'ClosureCriteria' => $closureCriteria,
                    'Notes' => $notes,
                    'ClosureStatement' => $closureStatement
                ));


        }

        $TBS->MergeBlock('a', $data);

Template Screenshot

Page Template


Solution

  • The solution is explained in the DOCX template of the OpenTBS demo provided in the OpenTBS package :

    1. Make sure that the first paragraph of the page has the property giving a page break before.
    2. Use a block defined with the alias tbs:page. This alias is given by OpenTBS and it helps to found the bounds of the page (or pages) according to the page-break defined in the paragraph properties

    Example: [a.ActionItemID;block=tbs:page]