Skip to content

Commit a15a9b5

Browse files
committed
ADDED : Writer/RTF for generating a simple file with some formatting texts and paragraphs
1 parent bedf584 commit a15a9b5

File tree

3 files changed

+465
-0
lines changed

3 files changed

+465
-0
lines changed

src/PHPWord/Shared/Drawing.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,32 @@ public static function centimetersToPixels($pValue = 0) {
123123
return 0;
124124
}
125125
}
126+
127+
/**
128+
* Convert HTML hexadecimal to RGB
129+
*
130+
* @param str $pValue HTML Color in hexadecimal
131+
* @return array Value in RGB
132+
*/
133+
public static function htmlToRGB($pValue) {
134+
if ($pValue[0] == '#'){
135+
$pValue = substr($pValue, 1);
136+
}
137+
138+
if (strlen($pValue) == 6){
139+
list($color_R, $color_G, $color_B) = array($pValue[0].$pValue[1],$pValue[2].$pValue[3],$pValue[4].$pValue[5]);
140+
}
141+
elseif (strlen($pValue) == 3){
142+
list($color_R, $color_G, $color_B) = array($pValue[0].$pValue[0],$pValue[1].$pValue[1],$pValue[2].$pValue[2]);
143+
}
144+
else{
145+
return false;
146+
}
147+
148+
$color_R = hexdec($color_R);
149+
$color_G = hexdec($color_G);
150+
$color_B = hexdec($color_B);
151+
152+
return array($color_R, $color_G, $color_B);
153+
}
126154
}

src/PHPWord/Style.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,19 @@ public static function addTitleStyle($titleCount, $styleFont, $styleParagraph =
147147
public static function getStyles() {
148148
return self::$_styleElements;
149149
}
150+
151+
/**
152+
* Get style
153+
*
154+
* @param string
155+
* @return PHPWord_Style
156+
*/
157+
public static function getStyle($styleName) {
158+
if(array_key_exists($styleName, self::$_styleElements)){
159+
return self::$_styleElements[$styleName];
160+
} else {
161+
return null;
162+
}
163+
}
150164
}
151165
?>

0 commit comments

Comments
 (0)