PHPWord icon indicating copy to clipboard operation
PHPWord copied to clipboard

Can't retrieve font details!! Please HELP URGENT

Open pratikchopra opened this issue 8 years ago • 1 comments

Upon loading a .docx file using load() and getting the elements and on using getSize() or any other font related method to get the parameters it won't show. So I used print_r() to check it out and found that all fields are empty and don't have values. Need the values for a project any solution would be appreciated. Thanks in advance. P.S : Even if I use textrun to create a file and retrieve that as another file won't happen.

<?php
include_once 'Sample_Header.php';

// Read contents
$name = basename(__FILE__, '.php');
$source = __DIR__ . "/results/test1.docx";

echo date('H:i:s'), " Reading contents from `{$source}`", EOL;
$phpWord = \PhpOffice\PhpWord\IOFactory::load($source);

$sections = $phpWord->getSections();
$section = $sections[0]; 
$arrays = $section->getElements();
echo sizeof($arrays)."<br/>";
$text = $arrays[0]->getElements();
print_r($text);
echo $text[0]->getText()."<br/>";
$fontstyle = $text[0]->getFontStyle();
//print_r($fontstyle);
$fontval = $fontstyle->getStyleValues();
echo $fontstyle->getSize();
?>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

pratikchopra avatar Feb 16 '17 08:02 pratikchopra

@pratikchopra Hi, Could you send the file with error for reproducing the issue, please ?

Progi1984 avatar Aug 22 '24 19:08 Progi1984