Categories > OpenTBS with DOCX >

Corrupt output 3

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Bang
Date: 2014-04-02
Time: 18:25

Corrupt output 3

Hi,
I also have the same problem. I only want to merge text. I use MS Word 2007. Are there somebody have solved the problem?
By: Bang
Date: 2014-04-03
Time: 09:55

Re: Corrupt output

Hi,

thank you for your fast answer!

I findout, that the .docx output is currupt when i use: $TBS->Show(OPENTBS_DOWNLOAD, $file_name);
When i use $TBS->Show(OPENTBS_FILE, $file_name);
the output is correct.

this follow information i get from from phpinfo():
-------------------------------------------------------
PHP Version 5.5.9

System  Windows NT 
Build Date  Feb 5 2014 12:55:32 
Compiler  MSVC11 (Visual C++ 2012) 
Architecture  x86 
Configure Command  cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--disable-static-analyze" "--with-pgo" 
Server API  Built-in HTTP server 
Virtual Directory Support  enabled 
Configuration File (php.ini) Path  C:\WINDOWS 
Loaded Configuration File  C:\xampp_v1_8_3\php\php.ini 
Scan this dir for additional .ini files  (none) 
Additional .ini files parsed  (none) 
PHP API  20121113 
PHP Extension  20121212 
Zend Extension  220121212 
Zend Extension Build  API220121212,TS,VC11 
PHP Extension Build  API20121212,TS,VC11 
Debug Build  no 
Thread Safety  enabled 
Zend Signal Handling  disabled 
Zend Memory Manager  enabled 
Zend Multibyte Support  provided by mbstring 
IPv6 Support  enabled 
DTrace Support  disabled 
Registered PHP Streams php, file, glob, data, http, ftp, zip, compress.zlib, compress.bzip2, https, ftps, phar
Registered Stream Socket Transports tcp, udp, ssl, sslv3, sslv2, tls
Registered Stream Filters convert.iconv.*, mcrypt.*, mdecrypt.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, zlib.*, bzip2.*
------------------------------------------------------------------------------------

By: Bang
Date: 2014-04-07
Time: 09:39

Re: Corrupt output

it is only one line in the docx file.:
Hello [onshow.author]

But I will send it to your email
By: Skrol29
Date: 2014-04-07
Time: 23:33

Re: Corrupt output 3

This message has been placed in a new thread.
By: Skrol29
Date: 2014-04-07
Time: 23:43

Re: Corrupt output 3

Hi Bang,

I can see no problem in your template.
If your PHP script makes a download instead of a file saved on the server, then there may be a PHP notice that it sent with the binary content just before the download.
You can check this in 3 ways :
1) Look at the binary contents of the merged DOCX, yu may see a PHP error notice at the beginning of the contents.
or
2) Save the result as a file on the server instead of a download, this will let yu read the PHP errors or notices on the web page.
or
3) Activate the OpenTBS debug mode.
By: Bang
Date: 2014-04-08
Time: 13:09

Re: Corrupt output 3

Hi Skrol29,

I activated the OpenTBS debug mode and I get the following output:

* 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.8.3 * TinyButStrong version: 3.9.0 * PHP version: 5.5.9 * Opened document: ./templateDocx/demo.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

I Think, that my problem occur because Zlib is not realy enabled!
For enanble Zlib, I only change the following line in php.ini:

zlib.output_compression=On

By: Skrol29
Date: 2014-04-08
Time: 22:11

Re: Corrupt output 3

Did this solve your problem ?
By: Bang
Date: 2014-04-10
Time: 13:16

Re: Corrupt output 3

no. I only want to say, that for enable Zlib, i only change 

zlib.output_compression=On

in php.ini, But i'am not sure, that Zlib are enabled now or not.

The .docx file only include:
Hello [onshow.author]

The .php file only include:
<?php
$author = 'Bang';
$TBS = new clsTinyButStrong;
$TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN);
$TBS->LoadTemplate('./templateDocx/demo.docx');
$TBS->Show(OPENTBS_DOWNLOAD, 'test.docx');
?>
By: Skrol29
Date: 2014-04-10
Time: 13:57

Re: Corrupt output 3

can you do a
var_export($TBS->TbsZip->Meth8Ok);

Or

var_export(extension_loaded('zlib'));
By: Bang
Date: 2014-04-10
Time: 14:09

Re: Corrupt output 3

The return of funktions:

var_export($TBS->TbsZip->Meth8Ok);

and

var_export(extension_loaded('zlib'));

is 'true'.
By: Skrol29
Date: 2014-04-10
Time: 14:41

Re: Corrupt output 3

So zlib is installed.
So your problem is somewhere else.

Can you do a $TBS->PlugIn(OPENTBS_DEBUG_XML_SHOW); ?
By: Bang
Date: 2014-04-10
Time: 15:17

Re: Corrupt output 3

Hi Skrol29,

I found my problem.

I have a empty line before my php-code. When I delete this empty line, so I can download and open the docx file normaly.

but why it is so?
By: Skrol29
Date: 2014-04-10
Time: 18:37

Re: Corrupt output 3

During the download, all output is for the downloaded file.
So if there is any other binary sent during the download, then the binary downloaded is corrupted.
By: Bang
Date: 2014-04-11
Time: 15:59

Re: Corrupt output 3

Hi Skrol29,

Thank You very much.