Load MS Word 2007 document with TinyButStrong class and no file extension .docx
-
15-11-2019 - |
Domanda
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 ?
Soluzione 3
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.
Altri suggerimenti
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
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.