Categories > OpenTBS with DOCX >

Scriptcase and OpenTBS - word document corrupted

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Annie
Date: 2012-10-07
Time: 13:45

Scriptcase and OpenTBS - word document corrupted

Hi,
I'm using Scriptcase to improve a database application and OpenTBS for printing reports in MS Word.
I used OpenTBS many times with no issues, but this time I'm going crazy with it.
The merged word document results in a corrupted document that MS Word won't automatically open when downloaded.
Trying DEBUG mode I receive this message:

<br /><b>TinyButStrong Error</b> OpenTBS Plugin: File &quot;&quot; is not found in the Central Directory. The process is ending, unless you set NoErr property to true.<br />
* 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.1
* PHP version: 5.3.5
* Opened document:
* Activated features for document type: (none)

* Deleted files in the archive: none
* Added files in the archive: none
* Modified files in the archive: none

------------------------------
File merged with OpenTBS: (id=)
------------------------------

I cannot understand first line beacuse if I use the same Word template with another application it woks fine.
I think it belong to Scriptcase, but I don't know how.
Any idea will be really appreciated!
Thank you
By: Skrol29
Date: 2012-10-08
Time: 02:23

Re: Scriptcase and OpenTBS - word document corrupted

Hi Annie,

This error message means that you script is trying to open a sub-file which name is an empty string.
The information of the Debug Mode also says that there is no opened documents, with no identified document type.

This may happens if your script is trying merge the template while LoadTemplate() has not been performed, or if Show() has been called twice.
You can try a $TBS->PlugIn(OPENTBS_DEBUG_XML_CURRENT) after the LoadTemplate() in order to check if it is correctly taken in account.
By: Annie
Date: 2012-10-08
Time: 07:02

Re: Scriptcase and OpenTBS - word document corrupted

Hi Skrol,
thanks for your reply.
I tried with $TBS->PlugIn(OPENTBS_DEBUG_XML_CURRENT) but the strange thing is that I get the corrupted merged document but not the debug page.
Here is my code
include_once('tbs/tbs_class.php');
include_once('tbs/tbs_plugin_opentbs.php');

$TBS = new clsTinyButStrong;
$TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN);


          
          
            // Retrieve the template to open
$template = 'Lettera_reso.docx';
       
$TBS->LoadTemplate($template);
$TBS->PlugIn(OPENTBS_DEBUG_XML_CURRENT);        

$data = mysql_query("SELECT AN_RagSociale, AN_Indirizzo, AN_CAP, AN_Localita, AN_Prov FROM anaperdism WHERE AN_CodFiliale LIKE '". $_GET['codfil'] ."'");       


$TBS->MergeBlock('a', $data);
           
           
            // Define the name of the output file
            $file_name =str_replace('.','_'. $_SESSION['codfil'] .'.',$template);
           
            // Output as a download file (some automatic fields are merged here)
            $TBS->Show(OPENTBS_DOWNLOAD, $file_name);

Maybe there's an error that I can't see...
Thank you
By: Annie
Date: 2012-10-08
Time: 22:05

Re: Scriptcase and OpenTBS - word document corrupted

Hi Skrol,
finally I've my debug page.
I sent you an email with the result because it's very long.
As you can see file seems to be merged correctly but after the footer you’ll find a big quantity of strange characters.
I don’t think it’s an issue related to the Word template itself because same template used in another web application works fine and also I tried to make a completely new template with same result.
I think this behavior depends on Scriptcase…but I don’t know how.
Do you have any idea?
Thank you for your patience and for your great job!

Annie