Stack Overflow Asked by patmin on November 27, 2021
I can successfully manipulate fields in the header and footer sections of a DOCX document with TinyButStrong (TBS) through this code:
$TBS->PlugIn(OPENTBS_SELECT_HEADER);
$TBS->MergeField('abk', 'ainfo', true);
$TBS->PlugIn(OPENTBS_SELECT_FOOTER);
$TBS->MergeField('abk', 'ainfo', true);
However, this does not work with an ODT file that is just the DOCX file saved in a different format through LibreOffice.
I found out that I can make it work by manually selecting the enclosed file "style.xml", but this seems not the right way to do it as it does not address a document section in the abstract sense:
$TBS->PlugIn(OPENTBS_SELECT_FILE, 'styles.xml');
$TBS->MergeField('abk', 'ainfo', true);
Does anybody have a better solution?
I later found out that a multi-section DOCX document causes a similar problem and only its first section is processed. As Skrol29, the maintainer of openTBS, kindly noted, there is a small bug in version 1.10.0 that prevents proper selection of document parts. As a workaround do this:
$TBS->PlugIn(OPENTBS_SELECT_FILE, 'word/header2.xml', false);
$TBS->MergeField('abk', 'ainfo', true);
Proceed with all the sections (header3, header4...) you have. Note that the footers need extra selection.
Answered by patmin on November 27, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP