Read README.md
This commit is contained in:
parent
891798bc16
commit
3037fbf59e
|
|
@ -150,6 +150,9 @@ class PHPWord_Section_Settings
|
|||
*/
|
||||
private $_borderBottomColor;
|
||||
|
||||
private $_colsNum;
|
||||
private $_colsSpace;
|
||||
|
||||
/**
|
||||
* Create new Section Settings
|
||||
*/
|
||||
|
|
@ -170,6 +173,8 @@ class PHPWord_Section_Settings
|
|||
$this->_borderRightColor = null;
|
||||
$this->_borderBottomSize = null;
|
||||
$this->_borderBottomColor = null;
|
||||
$this->_colsNum = 1;
|
||||
$this->_colsSpace = 360;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -542,4 +547,19 @@ class PHPWord_Section_Settings
|
|||
{
|
||||
return $this->_borderBottomColor;
|
||||
}
|
||||
|
||||
public function getColsNum() {
|
||||
return $this->_colsNum;
|
||||
}
|
||||
public function setColsNum($pValue = '') {
|
||||
$this->_colsNum = $pValue;
|
||||
return $this;
|
||||
}
|
||||
public function getColsSpace() {
|
||||
return $this->_colsSpace;
|
||||
}
|
||||
public function setColsSpace($pValue = '') {
|
||||
$this->_colsSpace = $pValue;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,6 +109,16 @@ class PHPWord_Section_TextRun
|
|||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a TextBreak Element
|
||||
*
|
||||
* @param int $count
|
||||
*/
|
||||
public function addTextBreak($count = 1) {
|
||||
for($i=1; $i<=$count; $i++) {
|
||||
$this->_elementCollection[] = new PHPWord_Section_TextBreak();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get TextRun content
|
||||
*
|
||||
|
|
|
|||
|
|
@ -73,6 +73,12 @@ class PHPWord_Style_Paragraph
|
|||
*/
|
||||
private $_indent;
|
||||
|
||||
/**
|
||||
* Hanging by how much
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_hanging;
|
||||
|
||||
/**
|
||||
* New Paragraph Style
|
||||
|
|
@ -85,6 +91,7 @@ class PHPWord_Style_Paragraph
|
|||
$this->_spacing = null;
|
||||
$this->_tabs = null;
|
||||
$this->_indent = null;
|
||||
$this->_hanging = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -96,7 +103,10 @@ class PHPWord_Style_Paragraph
|
|||
public function setStyleValue($key, $value)
|
||||
{
|
||||
if ($key == '_indent') {
|
||||
$value = (int)$value * 720; // 720 twips per indent
|
||||
$value = $value * 1440 / 2.54; // Measured by cm
|
||||
}
|
||||
if ($key == '_hanging') {
|
||||
$value = $value * 1440 / 2.54; // Measured by cm
|
||||
}
|
||||
if ($key == '_spacing') {
|
||||
$value += 240; // because line height of 1 matches 240 twips
|
||||
|
|
@ -221,6 +231,28 @@ class PHPWord_Style_Paragraph
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hanging
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHanging()
|
||||
{
|
||||
return $this->_hanging;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hanging
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setHanging($pValue = null)
|
||||
{
|
||||
$this->_hanging = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tabs
|
||||
*
|
||||
|
|
|
|||
|
|
@ -106,6 +106,8 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
$this->_writeText($objWriter, $element, true);
|
||||
} elseif ($element instanceof PHPWord_Section_Link) {
|
||||
$this->_writeLink($objWriter, $element, true);
|
||||
} elseif($element instanceof PHPWord_Section_TextBreak) {
|
||||
$objWriter->writeElement('w:br');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -120,6 +122,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
$spaceAfter = $style->getSpaceAfter();
|
||||
$spacing = $style->getSpacing();
|
||||
$indent = $style->getIndent();
|
||||
$hanging = $style->getHanging();
|
||||
$tabs = $style->getTabs();
|
||||
|
||||
if (!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($indent) || !is_null($tabs)) {
|
||||
|
|
@ -133,10 +136,15 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if (!is_null($indent)) {
|
||||
if (!is_null($indent) || !is_null($hanging)) {
|
||||
$objWriter->startElement('w:ind');
|
||||
$objWriter->writeAttribute('w:firstLine', 0);
|
||||
$objWriter->writeAttribute('w:left', $indent);
|
||||
if (!is_null($indent)) {
|
||||
$objWriter->writeAttribute('w:left', $indent);
|
||||
}
|
||||
if (!is_null($hanging)) {
|
||||
$objWriter->writeAttribute('w:hanging', $hanging);
|
||||
}
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
|
|
@ -320,6 +328,8 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
$fgColor = $style->getFgColor();
|
||||
$striketrough = $style->getStrikethrough();
|
||||
$underline = $style->getUnderline();
|
||||
$superscript = $style->getSuperScript();
|
||||
$subscript = $style->getSubScript();
|
||||
|
||||
$objWriter->startElement('w:rPr');
|
||||
|
||||
|
|
@ -379,6 +389,13 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
// Superscript/subscript
|
||||
if ($superscript || $subscript) {
|
||||
$objWriter->startElement('w:vertAlign');
|
||||
$objWriter->writeAttribute('w:val', $superscript ? 'superscript' : 'subscript');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,6 +137,9 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
|
|||
|
||||
$borders = $_settings->getBorderSize();
|
||||
|
||||
$colsNum = $_settings->getColsNum();
|
||||
$colsSpace = $_settings->getColsSpace();
|
||||
|
||||
$objWriter->startElement('w:sectPr');
|
||||
|
||||
foreach ($_headers as &$_header) {
|
||||
|
|
@ -227,7 +230,10 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
|
|||
|
||||
|
||||
$objWriter->startElement('w:cols');
|
||||
$objWriter->writeAttribute('w:space', '720');
|
||||
if($colsNum > 1){
|
||||
$objWriter->writeAttribute('w:num', $colsNum);
|
||||
}
|
||||
$objWriter->writeAttribute('w:space', $colsSpace);
|
||||
$objWriter->endElement();
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,27 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base
|
|||
// Write DocDefaults
|
||||
$this->_writeDocDefaults($objWriter);
|
||||
|
||||
// Write Normal
|
||||
// Start Hack
|
||||
$objWriter->startElement('w:style');
|
||||
$objWriter->writeAttribute('w:type', 'paragraph');
|
||||
$objWriter->writeAttribute('w:default', '1');
|
||||
$objWriter->writeAttribute('w:styleId', 'Normal');
|
||||
|
||||
$objWriter->startElement('w:name');
|
||||
$objWriter->writeAttribute('w:val', 'Normal');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('w:pPr');
|
||||
$objWriter->startElement('w:spacing');
|
||||
$objWriter->writeAttribute('w:before', 20 * 0);
|
||||
$objWriter->writeAttribute('w:after', 20 * 0);
|
||||
$objWriter->writeAttribute('w:line', 240 * 1);
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
// End Hack
|
||||
|
||||
// Write Style Definitions
|
||||
$styles = PHPWord_Style::getStyles();
|
||||
|
|
@ -92,6 +113,10 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base
|
|||
$objWriter->endElement();
|
||||
|
||||
if (!is_null($paragraphStyle)) {
|
||||
// 2013-12-31 11:34 IL
|
||||
$objWriter->startElement('w:basedOn');
|
||||
$objWriter->writeAttribute('w:val', 'Normal');
|
||||
$objWriter->endElement();
|
||||
$this->_writeParagraphStyle($objWriter, $paragraphStyle);
|
||||
}
|
||||
|
||||
|
|
@ -109,6 +134,11 @@ class PHPWord_Writer_Word2007_Styles extends PHPWord_Writer_Word2007_Base
|
|||
$objWriter->writeAttribute('w:val', $styleName);
|
||||
$objWriter->endElement();
|
||||
|
||||
// 2013-12-31 11:34 IL
|
||||
$objWriter->startElement('w:basedOn');
|
||||
$objWriter->writeAttribute('w:val', 'Normal');
|
||||
$objWriter->endElement();
|
||||
|
||||
$this->_writeParagraphStyle($objWriter, $style);
|
||||
$objWriter->endElement();
|
||||
|
||||
|
|
|
|||
10
README.md
10
README.md
|
|
@ -1,9 +1,17 @@
|
|||
# PHPWord - OpenXML - Read, Write and Create Word documents in PHP
|
||||
|
||||
PHPWord is a library written in PHP that create word documents.
|
||||
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
|
||||
|
||||
* 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!
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue