Categories > OpenTBS with DOCX >

Problem when i create a .docx file

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Mik89
Date: 2015-11-23
Time: 16:11

Problem when i create a .docx file

Hi to everybody,
i have a problem when i create a .docx file. It works perfectly till i open the file. My microsoft word (word 2010) show the error "it's impossible to open the file because of content problems".
I tried to load a .odt template and save an .odt file but the problem is the same.
How can i fix that?
This is my php code:

include_once('../tbs_us/tbs_class.php');
include_once('../tbs_us/plugins/tbs_plugin_opentbs.php');
$TBS = new clsTinyButStrong;
$TBS -> Plugin(TBS_INSTALL, OPENTBS_PLUGIN);

$titolo     = 'titolo';
$testo     = 'testo';

// OGGETTO TBS
$mod = '../doc/modelli/libreria.odt';
$titolo    = mb_convert_encoding($titolo,'ISO-8859-15','UTF-8');
$testo    = mb_convert_encoding($testo,'ISO-8859-15','UTF-8');

$out = 'libreria.odt';

$TBS -> LoadTemplate($mod);
$TBS->Show(OPENTBS_DOWNLOAD, $out); 

and this is the template:
[onshow.titolo]
[onshow.testo]

Thanks and regards.

Michele
By: Skrol29
Date: 2015-11-23
Time: 22:12

Re: Problem when i create a .docx file

Hi Mike,

I can see two thinks to check :

1) First check that all is UTF8 is your script and you data :
- use $TBS->LoadTemplate($mod, OPENTBS_ALREADY_UTF8);
- your script should be UTF-8 encoded
- your database connexion (if any) must return UTF-8 encoded results

2) The  check that your PHP script return no extra characters during the merging.
The debug mode can help you on this:
$TBS->PlugIn(OPENTBS_DEBUG_XML_SHOW)
By: Mik89
Date: 2015-11-24
Time: 10:03

Re: Problem when i create a .docx file

Thanks Skrol29,

It works perfectly with normal text but it doesn't work with html text.
If i use html text i see tags in the docx file.
What can i do to fix that?

Thanks a lot!

Michele
By: Skrol29
Date: 2015-11-25
Time: 23:54

Re: Problem when i create a .docx file

You need a converter HTML to DOCX.
I don't know such a tool.
You can search in the forum for converting some HTML entities to DOCX compatible contents.
There is no nice solution since the two formats are so differents.
By: Mik89
Date: 2015-11-26
Time: 14:42

Re: Problem when i create a .docx file

Thanks for your help Skrol29!
I know what i have to seach now.

Thanks a lot and regards!

Michele