diff --git a/Classes/PHPWord/Section/Settings.php b/Classes/PHPWord/Section/Settings.php index 87596a3e..c005ae40 100755 --- a/Classes/PHPWord/Section/Settings.php +++ b/Classes/PHPWord/Section/Settings.php @@ -152,6 +152,7 @@ class PHPWord_Section_Settings private $_colsNum; private $_colsSpace; + private $_breakType; /** * Create new Section Settings @@ -174,7 +175,8 @@ class PHPWord_Section_Settings $this->_borderBottomSize = null; $this->_borderBottomColor = null; $this->_colsNum = 1; - $this->_colsSpace = 360; + $this->_colsSpace = 0.5 * 1440 / 2.54; // in twips: 1 twip = 1/1440 in; 1 cm = 2.54 in + $this->_breakType = null; } /** @@ -562,4 +564,12 @@ class PHPWord_Section_Settings $this->_colsSpace = $pValue; return $this; } + + public function getBreakType() { + return $this->_breakType; + } + public function setBreakType($pValue = null) { + $this->_breakType = $pValue; + return $this; + } } diff --git a/Classes/PHPWord/Writer/Word2007/Document.php b/Classes/PHPWord/Writer/Word2007/Document.php index 32c69547..bcb5b756 100755 --- a/Classes/PHPWord/Writer/Word2007/Document.php +++ b/Classes/PHPWord/Writer/Word2007/Document.php @@ -139,6 +139,7 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base $colsNum = $_settings->getColsNum(); $colsSpace = $_settings->getColsSpace(); + $breakType = $_settings->getBreakType(); $objWriter->startElement('w:sectPr'); @@ -155,6 +156,13 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base $objWriter->endElement(); } + // http://www.schemacentral.com/sc/ooxml/a-w_val-43.html + if (!is_null($breakType)) { + $objWriter->startElement('w:type'); + $objWriter->writeAttribute('w:val', $breakType); + $objWriter->endElement(); + } + if (!is_null($_footer)) { $rId = $_footer->getRelationId(); $objWriter->startElement('w:footerReference'); diff --git a/README.md b/README.md index 8e57b9dd..ea995d2f 100755 --- a/README.md +++ b/README.md @@ -1,100 +1,16 @@ # PHPWord - OpenXML - Read, Write and Create Word documents in PHP PHPWord is a library written in PHP that create word documents. -No Windows operating system is needed for usage because the result are docx files (Office Open XML) that can be -opened by all major office software. -## Forked features by Ivan Lanin +## Add features in this fork * Superscript/subscript `w:vertAlign` * Hanging * Section with column * Softbreak (SHIFT + ENTER) in Text Run * Redefine normal paragraph style and base all other style from it - -## Want to contribute? -Fork us! - -## Requirements - -* PHP version 5.3.0 or higher +* Section `breakType`. Used especially for continuous column ## License + PHPWord is licensed under [LGPL (GNU LESSER GENERAL PUBLIC LICENSE)](https://github.com/PHPOffice/PHPWord/blob/master/license.md) - -## Installation - -It is recommended that you install the PHPWord library [through composer](http://getcomposer.org/). To do so, add -the following lines to your ``composer.json``. - -```json -{ - "require": { - "phpoffice/phpword": "dev-master" - } -} -``` - -## Usage - -The following is a basic example of the PHPWord library. - -```php -$PHPWord = new PHPWord(); - -// Every element you want to append to the word document is placed in a section. So you need a section: -$section = $PHPWord->createSection(); - -// After creating a section, you can append elements: -$section->addText('Hello world!'); - -// You can directly style your text by giving the addText function an array: -$section->addText('Hello world! I am formatted.', array('name'=>'Tahoma', 'size'=>16, 'bold'=>true)); - -// If you often need the same style again you can create a user defined style to the word document -// and give the addText function the name of the style: -$PHPWord->addFontStyle('myOwnStyle', array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232')); -$section->addText('Hello world! I am formatted by a user defined style', 'myOwnStyle'); - -// You can also putthe appended element to local object an call functions like this: -$myTextElement = $section->addText('Hello World!'); -$myTextElement->setBold(); -$myTextElement->setName('Verdana'); -$myTextElement->setSize(22); - -// At least write the document to webspace: -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); -$objWriter->save('helloWorld.docx'); -``` - -## Images - -You can add images easily using the following example. - -```php -$section = $PHPWord->createSection(); -$section->addImage('mars.jpg'); -``` - -Images settings include: - * ``width`` width in pixels - * ``height`` height in pixels - * ``align`` image alignment, __left__, __right__ or __center__ - * ``marginTop`` top margin in inches, can be negative - * ``marginLeft`` left margin in inches, can be negative - * ``wrappingStyle`` can be inline, __square__, __tight__, __behind__, __infront__ - - To add an image with settings, consider the following example. - - ```php -$section->addImage( - 'mars.jpg', - array( - 'width' => 100, - 'height' => 100, - 'marginTop' => -1, - 'marginLeft' => -1, - wrappingStyle => 'behind' - ) -); - ```