By: Javier G
Date: 2012-06-29
Time: 23:37
|
HTML field to be parsed in an odtHi, and thanks for TBS, it rocks!
I'm sending to the TBS plugin some block fields in order to create a Open Office/Libre Office document: odt. I'm actually creating a "letter" with the following fields: [letter;block=begin;comm=text:p] Hello [letter.receiver;], [letter.body;] Good bye [letter;block=end;comm=text:p] The problem is that my "letter.body" field has html: <p> and <br/>. Can I somehow convert them into a line breaks in the Open Office? Thanks a lot. |
||||
By: Skrol29
Date: 2012-07-02
Time: 01:38
|
Re: HTML field to be parsed in an odtHi Javier,
The same question has been posted on Stack Overflow about DOCX : http://stackoverflow.com/questions/9315531/opentbs-convert-html-tags-to-ms-word-tags But here is the answer for ODT: Since you have a conversion function for HTML to ODT, then you can implement it in OpenTBS using a custom PHP function and parameter "onformat". The following function only convert line breaks:
Use in the DOCX template :
About converting HTML to ODT : Converting a formated text into another formated text is quite often a nightmare. That's why is it wise to store the pure data instead if formated data. Converting HTML to ODT is quite difficult because the formating is not structured the same way. For example, bold or italic can be done in HTML using <b> and <i>, while you need styles in ODT. In HTML you can have text without <p>, hile in ODT, all text must be at least inside a <text:p>. |
||||
By: bill
Date: 2012-11-04
Time: 11:15
|
Re: HTML field to be parsed in an odtI need to convert <b>..,</b>. Making the question more general, is there a list of the ODT styles (like <text:line-break/>) that I can use to insert styes into a php string to be passed as text to ODF ?
Can the styles be imbedded into the php document, or does the translation have to happen in OpenTBS? |
||||
By: Skrol29
Date: 2012-11-04
Time: 19:51
|
Re: HTML field to be parsed in an odtWe can find a sort of list in the code of the Odt2Html project: http://bazaar.launchpad.net/~stephane-huc/odt2xhtml/trunk/view/head:/class/xsl/odt2xhtml.xsl |
||||
By: om
Date: 2013-03-11
Time: 23:48
|
Re: HTML field to be parsed in an odtI'm having trouble understanding how this works. I want to deal with some underlined html, so I modified the function like this:
on the PHP side, I have this:
on my template, I have this:
What I get in my merged document, is this:
In other words, instead of formatting the text, it is printing the formatting codes with the text. They're in the correct locations, but they are acting like text rather than formatting codes. Obviously that's not optimal. Anyway, I'm wondering where I'm going wrong and any help would be appreciated. Secondly, I'm working with a single line so it doesn't really need to be in an array, but I couldn't even get a document without doing a mergeblock, so I just stuck that single line in a very simple array. Can this process be used on strings? Also, my method for getting the ODT underline formatting code was to make a file with underlined text, save it, rename it *.zip, unzip it and read contents.xml. I'm hoping that the style name is not custom to my document in some way, but is generally used in all ODT documents. Am I thinking wrong? |