Open gaf09 opened 10 years ago
Hi @gaf09, Could you give us a sample code ?
Yes, I put the code here:
$PHPWord = new \PhpOffice\PhpWord\PhpWord();
// Load template
$template = $PHPWord->loadTemplate($WordFile);
// File name & directory
$tempFile = '../temp/' . time();
// Save template has new Word file
$template->saveAs($tempFile . ".docx");
// Load generated Word
$PHPWordLoad = \PhpOffice\PhpWord\IOFactory::load($tempFile . ".docx");
// Save generated word in HTML
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($PHPWordLoad, 'HTML');
$objWriter->save($tempFile . ".html");
I have also tried exporting to PDF but the same error with images. (because to save to PDF the system using HTML anyway).
PD: The template includes images
Could you give us your $WordFile for testing ?
Yes of course, here's my docx: https://www.dropbox.com/s/pyvkzi7prln6m2j/WordExample.docx
Here I also added the HTML generated by the sample code
<!DOCTYPE html>
<!-- Generated by PHPWord -->
<html>
<head>
<meta charset="UTF-8" />
<title>PHPWord</title>
<style>
* {font-family: Arial; font-size: 10pt;}
a.NoteRef {text-decoration: none;}
hr {height: 1px; padding: 0; margin: 1em 0; border: 0; border-top: 1px solid #CCC;}
.Normal {font-size: 12pt;}
.Hyperlink {text-decoration: underline ;}
.Cabecera y pie {font-family: 'Helvetica'; font-size: 12pt; color: #000000; font-weight: bold; font-style: italic; text-decoration: line-through ;}
.Cuerpo A {font-family: 'Helvetica'; font-size: 11pt; color: #000000; font-weight: bold; font-style: italic; text-decoration: line-through ;}
</style>
</head>
<body>
<p style="text-align: center;"><span style="font-size: 14pt; font-weight: bold;">C</span><span style="font-size: 14pt; font-weight: bold;">ó</span><span style="font-size: 14pt; font-weight: bold;">digo:</span><span style="font-size: 14pt;"> ${code}</span></p>
<p> </p>
<p style="text-align: center;"><span style="font-size: 14pt;">ASD :)</span></p>
<p> </p>
<p><span style="font-size: 14pt;">Otros datos:</span></p>
<p><span style="font-size: 14pt;">${message}</span></p>
<p><span style="font-family: 'Helvetica';"> </span></p>
<p style="text-align: right;"></p>
</body>
</html>
Hi @Progi1984 could have any idea why this error is happening ? Thanks!!
No for the moment, but we have all informations.
Hello, has anyone been able to resolve this? If yes, could you kindly provide details on how to go about it. Thank you.
Hello, I found out that DrawingML Objects (w:drawing) are not being parsed by the Word2007 Reader and also not supported by the HTML writer. Had to modify PHPWord to extract these and convert any WMF files into PNGs using Imagick since Browsers don't support WMFs.
The reader only interprets w:pict images, not w:drawing images in the MSWord XML. As a consequence, you need to drag and drop images into your word file for the conversion to work. Images that are copy pasted, or inserted using the menu will be ignored by phpword.
Hope this can serve as a workaround.
Some helps for which one who want to create a PR :
http://officeopenxml.com/drwPicInWord.php http://officeopenxml.com/drwPicInline.php http://officeopenxml.com/drwPicFloating.php
Hi,
Several hours ago I'm trying to find out why not working the HTML Writer, more specifically with the element Image of HTML Writer.
The error happens when i save a Word file that generates the HTML file, works with all elements excellently, but not work with the images. That is, it generates all the code less the "img" tag.
I hope they know what's going, Thanks and sorry for the bad English :)