php - How to insert conditional spaces in docx with opentbs (only if certain fields are not blank) -
i using opentbs generate reports in .docx format data entered users form, , able add spaces between fields conditionally. here's paradigm example of issue: user must enter street address (address1), fields before , after address field (business , address2, respectively) optional. there way set merge fields in template that, if user puts business field, document resulting merge have value of business field followed space, if user leaves field blank, document resulting merge not have either field or space? can see 2 possible ways of achieving this: 1. using stand-alone merge field prints space if field "business" not blank; or 2. using merge field in template prints both value of field , space, if field not blank.
here's psuedocode these 2 solutions: 1. [onshow.business][onshow;if[business]!=blank;then' ';else''][onshow.address1] 2. [onshow.business , ' '][onshow.address1]
it seems must possible, , yet haven't been able find way turn either pseudocode real, functioning merge fields in docx. template. i've searched of entries on forum , on tbs forum, documentation, issue hasn't squarely been raised, , things have tried have not worked. appreciated.
this insert non-breaking space after value of business, if not '':
[onshow.business; if [val] != ''; [val] ] the issue may encounter how word represents space... suggest starting inserting less problematic character ensure tag working correctly (like ^ or , a maybe), work on finding proper character / parameter combination make space work.
when start looking @ that, i'd try \s: http://www.tinybutstrong.com/forum.php?thr=3234 i'd @ xml:space="preserve": http://www.tinybutstrong.com/forum.php?thr=3263
it looks shows on <w:t> tag this: <w:t xml:space="preserve"> might try like:
php:
$f = 'preserve'; template:
[onshow.business; if [val] != ''; '[val] ';][onshow.p;att='xml:space'] there better way handle att should started @ least.
Comments
Post a Comment