Skip to content

Commit

Permalink
fix broken samples
Browse files Browse the repository at this point in the history
  • Loading branch information
troosan committed Dec 30, 2018
1 parent 54e7c6d commit b375b85
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
13 changes: 4 additions & 9 deletions samples/Sample_11_ReadWord97.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@
echo date('H:i:s'), " Reading contents from `{$source}`", EOL;
$phpWord = \PhpOffice\PhpWord\IOFactory::load($source, 'MsDoc');

// (Re)write contents
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
foreach ($writers as $writer => $extension) {
echo date('H:i:s'), " Write to {$writer} format", EOL;
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
$xmlWriter->save("{$name}.{$extension}");
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}

include_once 'Sample_Footer.php';
2 changes: 1 addition & 1 deletion samples/Sample_23_TemplateBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
echo date('H:i:s'), ' Saving the result document...', EOL;
$templateProcessor->saveAs('results/Sample_23_TemplateBlock.docx');

echo getEndingNotes(array('Word2007' => 'docx'), 'results/Sample_23_TemplateBlock.docx');
echo getEndingNotes(array('Word2007' => 'docx'), 'Sample_23_TemplateBlock');
if (!CLI) {
include_once 'Sample_Footer.php';
}
6 changes: 3 additions & 3 deletions samples/resources/Sample_30_ReadHTML.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ <h1>Adding element via HTML</h1>
<h2>Includes images</h2>
<img src="https://phpword.readthedocs.io/en/latest/_images/phpword.png" alt=""/>

<img src="https://localhost/gev/desarrollo/actividades/pruebas_14/5b064503587f7.jpeg" name="Imagen 12" align="bottom" width="208" height="183" border="0"/>
<img src="http://localhost/gev/desarrollo/actividades/pruebas_14/5b064503589db.png" name="Imagen 13" align="bottom" width="143" height="202" border="0"/>
<img src="http://localhost/gev/desarrollo/actividades/pruebas_14/5b0645035aac8.jpeg" name="Imagen 14" align="bottom" width="194" height="188" border="0"/>
<img src="http://php.net/images/logos/php-med-trans-light.gif" name="Imagen 12" align="bottom" width="208" height="183" border="0"/>
<img src="http://php.net/images/logos/php-icon.png" name="Imagen 13" align="bottom" width="143" height="202" border="0"/>
<img src="http://php.net/images/logos/php-med-trans-light.gif" name="Imagen 14" align="bottom" width="194" height="188" border="0"/>

</body>
</html>
18 changes: 11 additions & 7 deletions src/PhpWord/Writer/HTML/Element/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,23 @@ public function write()
/**
* Translates Table style in CSS equivalent
*
* @param \PhpOffice\PhpWord\Style\Table|null $tableStyle
* @param string|\PhpOffice\PhpWord\Style\Table|null $tableStyle
* @return string
*/
private function getTableStyle(\PhpOffice\PhpWord\Style\Table $tableStyle = null)
private function getTableStyle($tableStyle = null)
{
if ($tableStyle == null) {
return '';
}
$style = ' style="';
if ($tableStyle->getLayout() == \PhpOffice\PhpWord\Style\Table::LAYOUT_FIXED) {
$style .= 'table-layout: fixed;';
} elseif ($tableStyle->getLayout() == \PhpOffice\PhpWord\Style\Table::LAYOUT_AUTO) {
$style .= 'table-layout: auto;';
if (is_string($tableStyle)) {
$style = ' class="' . $tableStyle;
} else {
$style = ' style="';
if ($tableStyle->getLayout() == \PhpOffice\PhpWord\Style\Table::LAYOUT_FIXED) {
$style .= 'table-layout: fixed;';
} elseif ($tableStyle->getLayout() == \PhpOffice\PhpWord\Style\Table::LAYOUT_AUTO) {
$style .= 'table-layout: auto;';
}
}

return $style . '"';
Expand Down

0 comments on commit b375b85

Please sign in to comment.