|
| 1 | +.. _containers: |
| 2 | + |
| 3 | +Containers |
| 4 | +========== |
| 5 | + |
| 6 | +Sections |
| 7 | +-------- |
| 8 | + |
| 9 | +Every visible element in word is placed inside of a section. To create a |
| 10 | +section, use the following code: |
| 11 | + |
| 12 | +.. code:: php |
| 13 | +
|
| 14 | + $section = $phpWord->createSection($sectionSettings); |
| 15 | +
|
| 16 | +The ``$sectionSettings`` is an optional associative array that sets the |
| 17 | +section. Example: |
| 18 | + |
| 19 | +.. code:: php |
| 20 | +
|
| 21 | + $sectionSettings = array( |
| 22 | + 'orientation' => 'landscape', |
| 23 | + 'marginTop' => 600, |
| 24 | + 'colsNum' => 2, |
| 25 | + ); |
| 26 | +
|
| 27 | +Section settings |
| 28 | +~~~~~~~~~~~~~~~~ |
| 29 | + |
| 30 | +Below are the available settings for section: |
| 31 | + |
| 32 | +- ``orientation`` Page orientation, i.e. ‘portrait’ (default) or |
| 33 | + ‘landscape’ |
| 34 | +- ``marginTop`` Page margin top in twips |
| 35 | +- ``marginLeft`` Page margin left in twips |
| 36 | +- ``marginRight`` Page margin right in twips |
| 37 | +- ``marginBottom`` Page margin bottom in twips |
| 38 | +- ``borderTopSize`` Border top size in twips |
| 39 | +- ``borderTopColor`` Border top color |
| 40 | +- ``borderLeftSize`` Border left size in twips |
| 41 | +- ``borderLeftColor`` Border left color |
| 42 | +- ``borderRightSize`` Border right size in twips |
| 43 | +- ``borderRightColor`` Border right color |
| 44 | +- ``borderBottomSize`` Border bottom size in twips |
| 45 | +- ``borderBottomColor`` Border bottom color |
| 46 | +- ``headerHeight`` Spacing to top of header |
| 47 | +- ``footerHeight`` Spacing to bottom of footer |
| 48 | +- ``colsNum`` Number of columns |
| 49 | +- ``colsSpace`` Spacing between columns |
| 50 | +- ``breakType`` Section break type (nextPage, nextColumn, continuous, |
| 51 | + evenPage, oddPage) |
| 52 | + |
| 53 | +The following two settings are automatically set by the use of the |
| 54 | +``orientation`` setting. You can alter them but that’s not recommended. |
| 55 | + |
| 56 | +- ``pageSizeW`` Page width in twips |
| 57 | +- ``pageSizeH`` Page height in twips |
| 58 | + |
| 59 | +Section page numbering |
| 60 | +~~~~~~~~~~~~~~~~~~~~~~ |
| 61 | + |
| 62 | +You can change a section page numbering. |
| 63 | + |
| 64 | +.. code:: php |
| 65 | +
|
| 66 | + $section = $phpWord->createSection(); |
| 67 | + $section->getSettings()->setPageNumberingStart(1); |
| 68 | +
|
| 69 | +Headers |
| 70 | +------- |
| 71 | + |
| 72 | +Each section can have its own header reference. To create a header use |
| 73 | +the ``createHeader`` method: |
| 74 | + |
| 75 | +.. code:: php |
| 76 | +
|
| 77 | + $header = $section->createHeader(); |
| 78 | +
|
| 79 | +Be sure to save the result in a local object. You can use all elements |
| 80 | +that are available for the footer. See “Footer” section for detail. |
| 81 | +Additionally, only inside of the header reference you can add watermarks |
| 82 | +or background pictures. See “Watermarks” section. |
| 83 | + |
| 84 | +Footers |
| 85 | +------- |
| 86 | + |
| 87 | +Each section can have its own footer reference. To create a footer, use |
| 88 | +the ``createFooter`` method: |
| 89 | + |
| 90 | +.. code:: php |
| 91 | +
|
| 92 | + $footer = $section->createFooter(); |
| 93 | +
|
| 94 | +Be sure to save the result in a local object to add elements to a |
| 95 | +footer. You can add the following elements to footers: |
| 96 | + |
| 97 | +- Texts ``addText`` and ``createTextrun`` |
| 98 | +- Text breaks |
| 99 | +- Images |
| 100 | +- Tables |
| 101 | +- Preserve text |
| 102 | + |
| 103 | +See the “Elements” section for the detail of each elements. |
0 commit comments