Forum


Replies: 8   Views: 4615
Word error message when opening document
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 tonioseiler  · 19-05-2015 - 12:17

Hi, In an Application, we are generating a word document with phpdocx (V4.6). Everything seems fine, as long as I open the document in OpenOffice. When I open the document in MS Word, what most of the users of the app are likely to do, an error message appears. It's in german, but the meaning is something linke: "The File xyz.docx could not be opened, because the ontent is causing problems." When I click ok, a second error message appears: Something with unreadable content... I can then trust the document and is still opened and everything looks fine. After I save the document, the error messages disappear. Here is an example document: http://seiler-steinbach.com/apps/tmp/items_2015-05-19_14-03-50.docx Any Ideas. Thank you very much

Posted by admin  · 19-05-2015 - 12:29

Hello, Please send the DOCX to contact[at]phpdocx.com. When we open the URL we don't see any document but a web page. How are you generating the document? Are you merging two or more documents, using a template, from scratch? Regards.

Posted by tonioseiler  · 20-05-2015 - 21:47

I sent you the document by Email. FYI: I generate the document from a template.... Thanks

Posted by admin  · 21-05-2015 - 07:53

Hello, We've checked your document. At the top we see this info: Array ( [0] => Item.id [1] => Item: Id [2] => integer ) Array ( [0] => Item.title_en [1] => Item: Title (en) [2] => text ) ... That is not part of a DOCX document. It seems your code is adding a var_dump. Please it and remove that var_dump; also as test try running your script using the CLI mode to avoid external issues (such as web servers or mime type server). Regards.

Posted by tonioseiler  · 21-05-2015 - 08:53

After removing the dump, the error is still there. What i finally found out: My Document Structure is like this: Document -> table -> tablerow -> image -> something I am adding the image with: $imageFragment = new WordFragment($doc); $imageFragment->addImage($paramsImg); array_push($tableValues, array( array('value' => $imageFragment, 'borderTopSpacing' => 10, 'borderTop' => 'single', 'borderTopWidth' => 4, 'borderTopColor' => 'DDDDDD'), array('value' => $fieldFragment, 'borderTopSpacing' => 10, 'borderTop' => 'single', 'borderTopWidth' => 4, 'borderTopColor' => 'DDDDDD')) ); $doc->addTable($tableValues, $paramsTable); If I replace the addImage by addBreak, no error occurs...... It seems to have something to do with the image

Posted by tonioseiler  · 21-05-2015 - 11:41

OK. Here is my isolated sample code: $fileName = 'test'; $columnWidth = 3000; $template = WWW_ROOT.'files/templates/export-portrait.docx'; $docX = new CreateDocxFromTemplate($template); $docX->replaceVariableByText(array('TITLE' => 'Test'), array('target' => 'header', 'parseLineBreaks' => false)); $docX->replaceVariableByText(array('DATE' => date('d.m.Y'), 'FOOTER' => 'UES ART COLLECTION'), array('target' => 'footer', 'parseLineBreaks' => false)); $docX->enableCompatibilityMode(); $docX->setDefaultFont('Open Sans'); $tableValues = array(); $imageFragment = new WordFragment($docX); $paramsImg = array( 'src' => '/Users/tse/Documents/workspaces/web/ues-art-collection/app/tmp/thumbs//Samm3808.JPG', 'dpi' => 120, 'width' => intval(178.59), 'height' => intval(215.655849057), 'verticalOffset' => 0, 'textWrap' => 0, 'target' => 'document', 'spacingTop' => 0, 'spacingBottom' => 0, 'spacingLeft' => 0, 'spacingRight' => 0, 'borderWidth' => 0, 'rawWordML' => true, 'borderStyle' => 'none', 'borderColor' => 'FFFFFF', 'borderWidth' => 0 ); $imageFragment->addImage($paramsImg); array_push($tableValues, array( array('value' => $imageFragment, 'borderTopSpacing' => 10, 'borderTop' => 'single', 'borderTopWidth' => 4, 'borderTopColor' => 'DDDDDD', 'width' => intval($columnWidth)), array('value' => '', 'borderTopSpacing' => 10, 'borderTop' => 'single', 'borderTopWidth' => 4, 'borderTopColor' => 'DDDDDD', 'width' => intval(2 * $columnWidth))) ); array_push($tableValues, array('', '')); $paramsTable = array( 'textProperties' => array('fontSize' => 9), 'border' => 'none', 'borderSpacing' => 0, 'borderColor' => 'FFFFFF', 'columnWidths' => array(intval($columnWidth), intval(2 * $columnWidth - 1000)), 'cantSplitRows' => false, 'tableLayout' => 'fixed', 'tableWidth' => array('type' => 'dxa', 'value' => intval(3 * $columnWidth)) ); $docX->addTable($tableValues, $paramsTable); $docX->addBreak(array('type' => 'line')); $docX->removeTemplateVariable('EMPTY', 'block', 'document'); $fileName = 'tmp/'.$fileName; $docX -> createDocxAndDownload(WWW_ROOT.$fileName);

Posted by tonioseiler  · 21-05-2015 - 12:01

The Error occus if I comment out the ->addImage line. The error message I get (it's a translation, so its probably not that accurate): Not unique cell assignment detected.

elements are mandatory before every Is this any help???

Posted by admin  · 21-05-2015 - 12:42

Hello, Please send your script to the email address that has requested it. Also please send the template DOCX and images too. Regards.

Posted by admin  · 22-05-2015 - 06:52

Hello, This border style doesn't exist: 'borderStyle' => 'none' Please check the available border styles on: http://www.phpdocx.com/api-documentation/word-content/insert-image-Word-document-with-PHP If you remove the borderStyle or use one of the supported, the DOCX is generated perfectly. Regards.