Categories > OpenTBS with DOCX >

Word found unreadable content in ms word.

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Alvaro Garcia
Date: 2012-07-05
Time: 18:32

Word found unreadable content in ms word.

Hi, i was reading about this problem that i have in your forum about "Corrupt Simple Word (docx) File Problem". and i can not fix it.
i did read the link: http://www.tinybutstrong.com/forum.php?thr=2871

i did a document with ms word 2007 named template.docx  and i write next text:
  Hello this a test [onshow.yourname]

then i did a simple script en php. and i run the script, it download a file and when i try to open it, i get some error:  "Word found unreadable content in test2.docx.  Do you want to recover the contents of this document?  If you trust the source of this document, click Yes."

this is my script:
?php

  $template = 'template.docx';
  include_once('/lib/tbs_class_php5.php');
  include_once('/tbs/tbs_plugin_opentbs.php');
   
  $TBS = new clsTinyButStrong;
  $TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN); // load OpenTBS plugin
 
  $TBS->LoadTemplate($template);

  $yourname = 'Alvaro Garcia ';
  $file_name =  str_replace('.','_'.date('Y-m-d').'.',$template); 

$TBS->Show(OPENTBS_DOWNLOAD+TBS_EXIT, $file_name);

Q/ Do i have some error in php?
By: Skrol29
Date: 2012-07-06
Time: 01:36

Re: Word found unreadable content in ms word.

Hi Alvaro,

I've tried your snippet and it works fine for me.

The most common error when you have this message, is because your PHP code is outputting some extra unexpected contents. Such as a lost "echo", or with spaces or line breaks  before "<?php", or after "?>". This will make those extra characters to be concatenated with the DOCX binary contents.

In order to check if you have this problem, you should try with the Debug Mode:
  http://www.tinybutstrong.com/plugins/opentbs/tbs_plugin_opentbs.html#debug
By: Alvaro Garcia
Date: 2012-07-06
Time: 17:01

Re: Word found unreadable content in ms word.

Hi, skroll29. i test  file xml generated and it is fine.
Your demo, i did installed in my localhost and it work fine. Genera all files .docx, xlsx, odr very well.
Anyway i will be find out which is the problem.   Thank you.
This is the result. 

* OPENTBS DEBUG MODE: if the star, (*) on the left before the word OPENTBS, is not the very first character of this page, then your
merged Document will be corrupted when you use the OPENTBS_DOWNLOAD option. If there is a PHP error message, then you have to fix it.
If they are blank spaces, line beaks, or other unexpected characters, then you have to check your code in order to avoid them.

------------------------------
INFORMATION
------------------------------
* Debug command: OPENTBS_DEBUG_INFO
* OpenTBS version: 1.7.6
* TinyButStrong version: 3.8.0
* PHP version: 5.3.5
* Opened document: templateaga.docx
* Activated features for document type: openxml/docx

Charts inside the document:
---------------------------
  - (none)

******************
* OPENTBS DEBUG MODE: if the star, (*) on the left before the word OPENTBS, is not the very first character of this page, then your
merged Document will be corrupted when you use the OPENTBS_DOWNLOAD option. If there is a PHP error message, then you have to fix it.
If they are blank spaces, line beaks, or other unexpected characters, then you have to check your code in order to avoid them.

------------------------------
INFORMATION
------------------------------
* Debug command: OPENTBS_DEBUG_XML_SHOW
* OpenTBS version: 1.7.6
* TinyButStrong version: 3.8.0
* PHP version: 5.3.5
* Opened document: templateaga.docx
* Activated features for document type: openxml/docx
* Deleted files in the archive: none
* Added files in the archive: none
* Modified files in the archive:
  - word/document.xml

------------------------------
File merged with OpenTBS (XML reformated for debuging only): word/document.xml
------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xml:space="preserve">
<w:body>
  <w:p w:rsidRDefault="00936B9A">
   <w:r>
    <w:t>
     Hola esta es una prueba si el archive esta bien Alvaro Garcia Aguirre.
    </w:t>
   </w:r>
  </w:p>
  <w:p w:rsidRDefault="00E03792">
   <w:r>
    <w:t>
     Espero funcione bien
    </w:t>
   </w:r>
  </w:p>
  <w:sectPr w:rsidSect="00B85539">
   <w:pgSz w:w="12240" w:h="15840"/>
   <w:pgMar w:top="1417" w:right="1701" w:bottom="1417" w:left="1701" w:header="708" w:footer="708" w:gutter="0"/>
   <w:cols w:space="708"/>
   <w:docGrid w:linePitch="360"/>
  </w:sectPr>
</w:body>
</w:document>
By: Skrol29
Date: 2012-07-07
Time: 01:16

Re: Word found unreadable content in ms word.

The XML given by the Debug Mode is correct.
If you replace the content of "word/document.xml" with this one (previous message), then the document is valid.

So the hypothesis of extra character output is more probable.
Can you send to me a corrupted document?
By: Skrol29
Date: 2012-07-09
Time: 00:48

Re: Word found unreadable content in ms word.

I received your files.
The merged DOCX has an extra line-break at the very start of its binary content. This is usually because of a line-break break in your code before the "<?php" or after the "?>".
But the DOCX seems to have other problems. You should check to avoid all "echo" or other output command in your PHP script.
By: Alvaro Garcia
Date: 2012-07-09
Time: 15:13

Re: Word found unreadable content in ms word.

hi, Skrol29, Thanks you that was my problem.

In my code php i have a  a line-break before the "<?php".
I deleted this line y works fine!!!.

That tips is good know it.

Thanks you. and CONGRATULATIONS for your class, it is very useful and you help us to do our programing very easy.
I like TBS.
By: Skrol29
Date: 2012-07-10
Time: 15:37

Re: Word found unreadable content in ms word.

Thanks :)