0

I try to merge documents, with TBS library, but when I try to load a MS Word 2007 doc with $tbs->LoadTemplate($path_file). It doesn't work, I have no error, but the file generated is corrupted.

I know where the problem come from : $path_file has no extension .docx because if I try to load a file with .docx extension, all work properly. But I can't use this way, I must use file without extention (Files are uploaded by users on server and stored with no extension, and I can't change functions to upload files).

So what I want know is how can I open .docx whithout extension with TBS ?

2
  • if all the files are .docx then use $tbs->LoadTemplate($path_file.'.docx') or store your files with extension May 19, 2011 at 14:45
  • I can't store files in .docx and if I use $path_file.'.docx', it will not work, because this file doesn't exist (file existing is $path_file
    – Elorfin
    May 19, 2011 at 14:49

3 Answers 3

1

I guess you are using the OpenTBS plugin for TinyButStrong which makes Docx documents.

There is now a new version 1.6.0 which is still in beta but available for download yet. This last version is able to recognize the document type not only by its extension, but also by the sub-file which are saved in it. At the end, it also has a new command than enables you to force the document type.

See :

http://www.tinybutstrong.com/news.php

http://www.tinybutstrong.com/plugins/opentbs/tbs_plugin_opentbs.html

0

It's most likely not an extension issue, but a format issue.

.docx is an XML based file format. TBS can deal with placeholders in XML documents, so everything is fine - simple searching and replacing will work.

The old .doc file format is proprietary. Its structure is not known to the public, and it is not based on XML. You can't search and replace contents there like in a XML document.

What you want to do is probably not possible with old .doc files.

6
  • I have tried to open XML content explicitly using $path_file.'#word/document.xml', but same problem : it doesn't work
    – Elorfin
    May 19, 2011 at 14:50
  • @Corum well, is it a .docx file or is it not? If it's not, this has no chance of working.
    – Pekka
    May 19, 2011 at 14:52
  • Yes it is, but it hasn't got .docx extension
    – Elorfin
    May 19, 2011 at 14:56
  • And if you rename it to .docx after the conversion?
    – Pekka
    May 19, 2011 at 15:01
  • @Corum after running it through TBS
    – Pekka
    May 19, 2011 at 15:05
0

Problem resolves by creating a temp file with extension file (extension is stored in database). I load the template using temp, and I delete it just after.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.