#23 : Implement Word97 aka MsDoc Reader

This commit is contained in:
Progi1984 2014-08-15 19:26:23 +02:00
parent df8de962a9
commit ca69de3962
5 changed files with 2179 additions and 1190 deletions

View File

@ -5,15 +5,15 @@ include_once 'Sample_Header.php';
$name = basename(__FILE__, '.php');
$source = "resources/{$name}.doc";
echo date('H:i:s'), " Reading contents from `{$source}`", EOL;
$phpWord = \PhpOffice\PhpWord\IOFactory::load($source, 'Word97');
$phpWord = \PhpOffice\PhpWord\IOFactory::load($source, 'MsDoc');
// (Re)write contents
/*$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
$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}");
}*/
}
include_once 'Sample_Footer.php';

View File

@ -1,4 +1,7 @@
<?php
date_default_timezone_set('Europe/Paris');
/**
* Header file
*/

File diff suppressed because it is too large Load Diff

View File

@ -118,6 +118,76 @@ class Drawing
}
}
/**
* Convert centimeters width to twips
*
* @param integer $pValue
*/
public static function centimetersToTwips($pValue = 0)
{
if ($pValue != 0) {
return $pValue * 566.928;
} else {
return 0;
}
}
/**
* Convert twips width to centimeters
*
* @param integer $pValue
*/
public static function twipsToCentimeters($pValue = 0)
{
if ($pValue != 0) {
return $pValue / 566.928;
} else {
return 0;
}
}
/**
* Convert inches width to twips
*
* @param integer $pValue
*/
public static function inchesToTwips($pValue = 0)
{
if ($pValue != 0) {
return $pValue * 1440;
} else {
return 0;
}
}
/**
* Convert twips width to inches
*
* @param integer $pValue
*/
public static function twipsToInches($pValue = 0)
{
if ($pValue != 0) {
return $pValue / 1440;
} else {
return 0;
}
}
/**
* Convert twips width to pixels
*
* @param integer $pValue
*/
public static function twipsToPixels($pValue = 0)
{
if ($pValue != 0) {
return round($pValue / 15.873984);
} else {
return 0;
}
}
/**
* Convert HTML hexadecimal to RGB
*

View File

@ -225,7 +225,6 @@ class Font extends AbstractStyle
return $this;
}
/**
* Get font size
*