<?php
function readDocx($filePath) {
// Create new ZIP archive
$zip = new ZipArchive;
$dataFile = 'word/document.xml';
// Open received archive file
if (true === $zip->open($filePath)) {
// If done, search for the data file in the archive
if (($index = $zip->locateName($dataFile)) !== false) {
// If found, read it to the string
$data = $zip->getFromIndex($index);
// Close archive file
$zip->close();
// Load XML from a string
// Skip errors and warnings
$xml = DOMDocument::loadXML($data, LIBXML_NOENT | LIBXML_XINCLUDE | LIBXML_NOERROR | LIBXML_NOWARNING);
// Return data without XML formatting tags
$contents = explode('\n',strip_tags($xml->saveXML()));
$text = '';
foreach($contents as $i=>$content) {
$text .= $contents[$i];
}
return $text;
}
$zip->close();
}
// In case of failure return empty string
return "failed";
}
?>
13 Replies - 1431 Views - Last Post: 01 August 2012 - 06:23 PM
#1
PHPDocx not displaying images when a docx file with image is converted
Posted 24 July 2012 - 08:33 PM
Replies To: PHPDocx not displaying images when a docx file with image is converted
#2
Re: PHPDocx not displaying images when a docx file with image is converted
Posted 25 July 2012 - 07:08 AM
#3
Re: PHPDocx not displaying images when a docx file with image is converted
Posted 25 July 2012 - 07:41 AM
#4
Re: PHPDocx not displaying images when a docx file with image is converted
Posted 25 July 2012 - 08:25 AM
Quote
It seemed to me that the starting point is data. I think that something like this is happening:
Database -> DOCX -> Wordfile -> DOCX -> HTML
If that's the case, it would be easier to go straight to HTML.
#5
Re: PHPDocx not displaying images when a docx file with image is converted
Posted 25 July 2012 - 05:24 PM
#6
Re: PHPDocx not displaying images when a docx file with image is converted
Posted 25 July 2012 - 06:50 PM
it seems that when PHP docx tries to convert docx to html. The images are copied to this directory. I think PHP docx failed to copy it there. I tried viewing the source in the browser and find that image. This is where the image comes from. It just point to a directory but doesn’t point into a file
#7
Re: PHPDocx not displaying images when a docx file with image is converted
Posted 26 July 2012 - 01:11 AM
#8
Re: PHPDocx not displaying images when a docx file with image is converted
Posted 26 July 2012 - 07:05 PM
#9
Re: PHPDocx not displaying images when a docx file with image is converted
Posted 27 July 2012 - 01:08 AM
#10
Re: PHPDocx not displaying images when a docx file with image is converted
Posted 27 July 2012 - 02:55 AM
Duckington, on 27 July 2012 - 01:08 AM, said:
I already tried using mkdir("New Folder"); to create new folder. And its working. I think its the same process. But Im not still sure. I didn't put any .htaccess file inside the targetted directory. If there is more configuration about creating directory permissions, then what is it? and I will check it.
Did you use phpDocx? Have you tried the example inside that folder and trying to use the docxtohtml script?.. I really appreciate if you try.
#11
Re: PHPDocx not displaying images when a docx file with image is converted
Posted 27 July 2012 - 03:51 AM
Haev you checked your error log to see if anything is there?
(I'd also recommend creating your own error function to write errors to your own specific file, as that is more customisable and can make things easier to debug).
#12
Re: PHPDocx not displaying images when a docx file with image is converted
Posted 01 August 2012 - 05:31 PM
Ive got this error from apache...
#13
Re: PHPDocx not displaying images when a docx file with image is converted
Posted 01 August 2012 - 05:57 PM
C:/wamp/www/Testing Site/Tiny MCE UPLOAD AND SAVE TESTING/Test 4/phpdocx_free/examples/easy/files/files_
actually exist?
#14
Re: PHPDocx not displaying images when a docx file with image is converted
Posted 01 August 2012 - 06:23 PM
JackOfAllTrades, on 01 August 2012 - 05:57 PM, said:
C:/wamp/www/Testing Site/Tiny MCE UPLOAD AND SAVE TESTING/Test 4/phpdocx_free/examples/easy/files/files_
actually exist?
Ive tried making directory here's what I get. THe directory I make is depending on the last directory before the referrer:
[Thu Aug 02 08:29:19 2012] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/Testing Site/Tiny MCE UPLOAD AND SAVE TESTING/Test 4/phpdocx_free/examples/easy/files/files_, referer: http://localhost/Tes.../createHTML.php
[Thu Aug 02 08:30:05 2012] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/Testing Site/Tiny MCE UPLOAD AND SAVE TESTING/Test 4/phpdocx_free/examples/easy/files/files_, referer: http://localhost/Tes.../createHTML.php
[Thu Aug 02 08:31:02 2012] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/Testing Site/Tiny MCE UPLOAD AND SAVE TESTING/Test 4/phpdocx_free/examples/easy/files/files_, referer: http://localhost/Tes.../createHTML.php
[Thu Aug 02 09:13:07 2012] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/Testing Site/Tiny MCE UPLOAD AND SAVE TESTING/Test 4/phpdocx_free/examples/easy/files/files_/files, referer: http://localhost/Tes.../createHTML.php
[Thu Aug 02 09:14:59 2012] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/Testing Site/Tiny MCE UPLOAD AND SAVE TESTING/Test 4/phpdocx_free/examples/easy/files/files_/files/w.docx, referer: http://localhost/Tes.../createHTML.php
[Thu Aug 02 09:18:34 2012] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/Testing Site/Tiny MCE UPLOAD AND SAVE TESTING/Test 4/phpdocx_free/examples/easy/files/files_/files/w.docx/media/word/, referer: http://localhost/Tes.../createHTML.php
[Thu Aug 02 09:19:58 2012] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/Testing Site/Tiny MCE UPLOAD AND SAVE TESTING/Test 4/phpdocx_free/examples/easy/files/files_/files/w.docx/media, referer: http://localhost/Tes.../createHTML.php
[Thu Aug 02 09:20:27 2012] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/Testing Site/Tiny MCE UPLOAD AND SAVE TESTING/Test 4/phpdocx_free/examples/easy/files/files_/files/w.docx/media/word, referer: http://localhost/Tes.../createHTML.php
|
|

New Topic/Question
Reply



MultiQuote






|