RichText - Extract Body from HTML
Easy-to-use print report library and designer
Brought to you by:
aliks-os
Hey Alik,
I tested your html body extraction for RichText field and I suggest you to change it as above, since body tag has arguments and rarely will be "" and almost all times will be . So I changed the search string from "" to "<body". It works great :)
if ((currentFragment.text().contains("[") && currentFragment.text().contains("]")) ||
(currentFragment.text().contains("<") && currentFragment.text().contains(">")))
{
QString tmpTxt = sectionField(fieldObject->parentBand, currentFragment.text(), false, false, "");
QTextCursor c = document.find(currentFragment.text(),0,QTextDocument::FindWholeWords);
if (tmpTxt.isEmpty() || tmpTxt.isNull())
tmpTxt = " ";
if (tmpTxt.toLower().contains("<body") && tmpTxt.toLower().contains("</body>")) {
int start = tmpTxt.toLower().indexOf("<body");
int end = tmpTxt.toLower().indexOf("</body>")+1;
c.insertHtml(tmpTxt.mid(start,end));
} else
c.insertText(tmpTxt);
}
Regards
thank you, corrected