Forum


Replies: 8   Views: 4292
Transformdocument doesn't create output - v4.5
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by seb  · 04-03-2015 - 15:36

Hello, After trying all the examples and searching the forums, I can't make transformDocument() output anything. The script finishes but no transformed output is created. Example script: $docx = new Phpdocx\Create\CreateDocx(); $docx->enableCompatibilityMode(); $text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ' . 'enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut' . 'aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit ' . 'in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ' . 'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui ' . 'officia deserunt mollit anim id est laborum.'; $paramsText = array( 'b' => 'single', 'font' => 'Arial' ); $docx->addText($text, $paramsText); $docx->createDocx('example_text'); $docx->transformDocument('example_text.docx', 'example_text.html'); It just takes one or two seconds to run, creates the example_text.docx file, but doesn't create the HTML file. Am I doing something wrong here? Thanks, Seb

Posted by admin  · 04-03-2015 - 18:41

Hello, Please read all the documentation available on: http://www.phpdocx.com/conversion-plugin/index And follow the steps explained to debug OpenOffice or LibreOffice. We recommend you to use the conversion plugin that uses LibreOffice. Regards.

Posted by seb  · 05-03-2015 - 09:21

Ok I've found the problem. The conversion script works on the command line, but not through a web browser. The reason for this is the temporary ODT file it creates (like /tmp/tempOdt_54f81bba0e6ed.odt) has very low permissions on it: -rw------- 1 www-data www-data So the conversion java command always fails because it cannot read the input file. And because all script output is sent to dev/null you never get this error appear on the web page. I've fixed this by adding passthru('chmod 444 '.$tempDoc); just after line 112 after the initial passthru() command. While this works, is there a better way to do this? Thanks, Seb

Posted by admin  · 05-03-2015 - 10:23

Hello, There's a debug option in the transformDocument method to show all output. About your issue, you can set a new default umask or use chmod as you did or use the script option of the method to run it as a system user instead of the Apache user or use a handler like FastCGI. If you use LibreOffice instead of OpenOffice, this issue doesn't exist. Regards.

Posted by seb  · 05-03-2015 - 14:56

Hi, I've installed LibreOffice 4.1, and when I try to convert a .docx it works fine. if I try to convert a .doc, it wont work and I get a segmentation error. Is the libreoffice transformation incompatible with .doc files? Thanks, Seb

Posted by admin  · 05-03-2015 - 15:33

Hello, It's compatible. Please upgrade to LibreOffice 4.3. Regards.

Posted by seb  · 06-03-2015 - 09:21

Installed LibreOffice 4.3 and still the same problem - segmentation error when trying to convert a .doc to HTML (.docx is fine). The problem is at line 70 in TransformDocAdv.inc where its treating the .doc file as a .docx zip archive. Its looking for a word/ folder in the .doc which doesn't exist, and therefore the $docXML variable is always empty when you try converting a .doc to HTML. So you then get PHP Warning: DOMDocument::loadXML(): Empty string supplied as input as an error, plus a backtrace. Is there something I'm missing here? Top part of the backtrace: *** glibc detected *** php: munmap_chunk(): invalid pointer: 0x0000000002b129b8 *** ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x7eb96)[0x7f5e842ffb96] php[0x64089d] php(zip_close+0x6bb)[0x63f77b] php[0x63b422] php[0x70ff8d] php(execute+0x1fb)[0x6c0afb] php(zend_execute_scripts+0x130)[0x69c060] php(php_execute_script+0x1d3)[0x6486d3] php[0x42c967] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7f5e842a276d] php[0x42c9b5] ======= Memory map: ======== 00400000-00b49000 r-xp 00000000 fc:00 56885350 /usr/bin/php5 00d48000-00dae000 r--p 00748000 fc:00 56885350 /usr/bin/php5 00dae000-00dba000 rw-p 007ae000 fc:00 56885350 /usr/bin/php5 00dba000-00dd6000 rw-p 00000000 00:00 0 023ff000-03e8e000 rw-p 00000000 00:00 0 [heap]

Posted by admin  · 06-03-2015 - 10:42

Hello, Please open the TransformDocAdvLibreOffice and remove the line that invoke the prepareDocx method. This issues has been fixed in the current dev and will be uploaded the next week to the stable packages. Regards.