Search code examples
phpopentbstinybutstrong

Can't load a .doc extension file with TBS/OPENTBS


I'm trying to load a .doc file (MS WORD 2007) with only Office. But I've a pop-up asking me the encoding type.

What is happening is that the template can't be loaded with errMsg.

But if I edit the file with only Office and then try to load it, it will work. how can I solve this?

Here is a part of the code:

} elseif ($extension == 'docx' || $extension == 'doc') {
                $tbs->LoadTemplate($args['path'], OPENTBS_ALREADY_UTF8);
                $templates = ['word/header1.xml', 'word/header2.xml', 'word/header3.xml', 'word/footer1.xml', 'word/footer2.xml', 'word/footer3.xml'];
                foreach ($templates as $template) {
                    if ($tbs->Plugin(OPENTBS_FILEEXISTS, $template)) {
                        $tbs->LoadTemplate("#{$template}", OPENTBS_ALREADY_UTF8);
                        foreach ($dataToBeMerge as $key => $value) {
                            $tbs->MergeField($key, $value);
                        }
                    }
                }
                $tbs->PlugIn(OPENTBS_SELECT_MAIN);

Solution

  • OpenTBS cannot work with DOC files, but it can work with DOCX. DOC is an old format file, based on binary contents. DOCX is le last format file, based on XLSX contents.