OpenTBS删除docx中带有格式化文本的空格

时间:2019-07-17 13:19:55

标签: php opentbs tinybutstrong

我有一个带格式文本的docx文件。合并变量后,结果文档中格式化文本前后的空格会消失。

这是我在示例中使用的代码:

include_once('../tbs/tbs_class.php'); // Load the TinyButStrong template engine
include_once('../open_tbs/tbs_plugin_opentbs.php'); // Load the OpenTBS plugin

// prevent from a PHP configuration problem when using mktime() and date()
if (version_compare(PHP_VERSION,'5.1.0')>=0) {
    if (ini_get('date.timezone')=='') {
        date_default_timezone_set('UTC');
    }
}

// Initialize the TBS instance
$TBS = new clsTinyButStrong; // new instance of TBS
$TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN); // load the OpenTBS plugin

$template = 'test_template_word.docx';//select templatename
$project_name = 'Test name';
//load template
$TBS->LoadTemplate($template, OPENTBS_ALREADY_UTF8); // Also merge some [onload] automatic fields (depends of the type of document).
//$TBS->LoadTemplate($template,OPENTBS_ALREADY_XML); // Also merge some [onload] automatic fields (depends of the type of document).

$output_file_name = str_replace('.', '_'.date('Y-m-d').$save_as.'.', $template);

$TBS->Show(OPENTBS_DOWNLOAD, $output_file_name); // Also merges all [onshow] automatic fields.

这是ms字模板test_template_word.docx 我该怎么做才能保留带有空格的原始格式文本?

这是合并后的结果文件:test_template_word_2019-07-20.docx

0 个答案:

没有答案