Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML writer error #285

Open
gaf09 opened this issue Jun 20, 2014 · 10 comments
Open

HTML writer error #285

gaf09 opened this issue Jun 20, 2014 · 10 comments

Comments

@gaf09
Copy link

gaf09 commented Jun 20, 2014

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 :)


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

@Progi1984
Copy link
Member

Hi @gaf09, Could you give us a sample code ?

@gaf09
Copy link
Author

gaf09 commented Jun 21, 2014

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

@Progi1984
Copy link
Member

Could you give us your $WordFile for testing ?

@gaf09
Copy link
Author

gaf09 commented Jun 22, 2014

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>&nbsp;</p>
<p style="text-align: center;"><span style="font-size: 14pt;">ASD :)</span></p>
<p>&nbsp;</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>

@gaf09
Copy link
Author

gaf09 commented Jun 25, 2014

Hi @Progi1984 could have any idea why this error is happening ? Thanks!!

@Progi1984
Copy link
Member

No for the moment, but we have all informations.

@shawlz
Copy link

shawlz commented Nov 6, 2014

Hello, has anyone been able to resolve this? If yes, could you kindly provide details on how to go about it. Thank you.

@shawlz
Copy link

shawlz commented Nov 7, 2014

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.

@ghost ghost added this to the Later milestone Nov 7, 2014
@ghost ghost assigned ivanlanin Nov 7, 2014
@laue
Copy link

laue commented Aug 31, 2016

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.

@Progi1984
Copy link
Member

@github-actions github-actions bot added the Stale label Nov 18, 2022
@Progi1984 Progi1984 removed the Stale label Nov 18, 2022
@PHPOffice PHPOffice deleted a comment from github-actions bot Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants