繁体   English   中英

opentbs - 如何以编程方式设置文档标题?

[英]opentbs - How can I set document title programmatically?

我使用 OpenTBS 1.9.6 生成 OpenOffice odt 文档。 我需要以编程方式在文档属性中设置标题。

我在文档属性标题中设置了占位符。 但它不起作用。

变量设置为全局 $TBS->VarRef

有什么办法吗? 谢谢

文档属性中的占位符

我使用 OpenTBS 1.9.6 和 TinyButStrong 3.10.1。 我使用 OpenOffice 4.1.5 创建的 odt 文件。


`        include_once($this->context->parameters['appDir'] . '/openTBS/tbs_class.php'); // Load the TinyButStrong template engine
        include_once($this->context->parameters['appDir'] . '/openTBS/tbs_plugin_opentbs.php'); // Load the OpenTBS plugin

$TBS = new \App\openTBS\clsTinyButStrong; $TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN); $TBS->LoadTemplate($this->context->parameters['documents_path'] .'templates/'. $templateName, OPENTBS_ALREADY_UTF8); $res = $TBS->PlugIn(OPENTBS_SELECT_FILE, 'meta.xml'); Debugger::log('OPENTBS_SELECT_FILE: '.$res); // function returned false $res = $TBS->PlugIn(OPENTBS_EDIT_ENTITY, 'meta.xml', 'office:document-meta/office:meta/dc:title', false, "My title", true); Debugger::log('OPENTBS_EDIT_ENTITY: '.$res); // function returned false

` odt file structure looks this way: 在此处输入图片说明 meta.xml looks this way:

` odt file structure looks this way: 在此处输入图片说明 meta.xml looks this way:

` odt file structure looks this way:在此处输入图片说明 meta.xml looks this way:

` odt file structure looks this way: 在此处输入图片说明 meta.xml looks this way:

<?xml version="1.0" encoding="UTF-8"?> <office:document-meta xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:textooo="http://openoffice.org/2013/office" office:version="1.2"><office:meta><meta:initial-creator>Lubor Voleský</meta:initial-creator><meta:creation-date>2019-01-09T22:04:27.08</meta:creation-date><dc:date>2020-04-07T18:30:26</dc:date><meta:editing-duration>PT20H5M8S</meta:editing-duration><meta:editing-cycles>26</meta:editing-cycles><meta:generator>OpenOffice/4.1.5$Unix OpenOffice.org_project/415m1$Build-9789</meta:generator><dc:description>comment</dc:description><meta:keyword>keywords</meta:keyword><dc:subject>Subject</dc:subject><dc:title>Title</dc:title><meta:document-statistic meta:table-count="1" meta:image-count="1" meta:object-count="0" meta:page-count="1" meta:paragraph-count="19" meta:word-count="39" meta:character-count="256"/><meta:user-defined meta:name="Producer">OpenTBS 1.9.6</meta:user-defined></office:meta></office:document-meta>

这些属性位于meta.xml子文件中。 因此,您只需打开它,然后将处理自动字段(onload、onshow):

$TBS->PlugIn(OPENTBS_SELECT_FILE, 'meta.xml');

您还可以使用特殊命令(较慢):

$TBS->PlugIn(OPENTBS_EDIT_ENTITY, 'meta.xml', 'office:document-meta/office:meta/dc:subject',     false, "My subject", true);
$TBS->PlugIn(OPENTBS_EDIT_ENTITY, 'meta.xml', 'office:document-meta/office:meta/dc:title',       false, "My title", true);
$TBS->PlugIn(OPENTBS_EDIT_ENTITY, 'meta.xml', 'office:document-meta/office:meta/dc:description', false, "My description", true);
$TBS->PlugIn(OPENTBS_EDIT_ENTITY, 'meta.xml', 'office:document-meta/office:meta/meta:keyword',   false, "My keywords", true);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM