convert html to text

Questions, tips and tricks and techniques for scripting in Servoy

convert html to text

Postby irenem » Fri Nov 07, 2008 4:19 pm

Hi,

I have a text_area field and I like to be able to format the content, so html or rtf seems to be the most convenient display type. But now I like to convert the formatted content to text for export reasons. Is there any way to do it?
Irene Meyer

Version: 6.0.5
Java version 1.6.0_29
Mac OS X Version 10.7.3
User avatar
irenem
 
Posts: 279
Joined: Tue Aug 28, 2007 2:09 pm
Location: Netherlands

Re: convert html to text

Postby ngervasi » Fri Nov 07, 2008 5:34 pm

Try this, it should help:

Code: Select all
//Returns the escaped markup text (HTML/XML)
var escapedText = utils.stringEscapeMarkup('<html><body>escape me</body></html>')
Nicola Gervasi
sintpro.com
SAN Partner
ngervasi
 
Posts: 1485
Joined: Tue Dec 21, 2004 12:47 pm
Location: Arezzo, Italy

Re: convert html to text

Postby irenem » Mon Nov 10, 2008 1:23 pm

Hi Nicola,

sorry it doesn't help. All what I get out is this:
"&lt;html&gt;&lt;body&gt;escape me&lt;/body&gt;&lt;/html&gt;"


What I would like to see is this

this sould be bold
and this maybe italic
Irene Meyer

Version: 6.0.5
Java version 1.6.0_29
Mac OS X Version 10.7.3
User avatar
irenem
 
Posts: 279
Joined: Tue Aug 28, 2007 2:09 pm
Location: Netherlands

Re: convert html to text

Postby Joas » Mon Nov 10, 2008 2:34 pm

So you just want the plain text without formatting, right?

To get this, make sure your the htmlarea has a name and do:
Code: Select all
elements.myname.getAsPlainText();
Joas de Haan
Yield Software Development
Need help on your project? yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 842
Joined: Mon Mar 20, 2006 4:07 pm
Location: Leusden, NL

Re: convert html to text

Postby irenem » Mon Nov 10, 2008 2:40 pm

Hi Joas,

nop, I want the formatted text. Thats why I have an html area, so that the user can format the text and export it.
Irene Meyer

Version: 6.0.5
Java version 1.6.0_29
Mac OS X Version 10.7.3
User avatar
irenem
 
Posts: 279
Joined: Tue Aug 28, 2007 2:09 pm
Location: Netherlands

Re: convert html to text

Postby ngervasi » Mon Nov 10, 2008 2:50 pm

irenem wrote:Hi Joas,

nop, I want the formatted text. Thats why I have an html area, so that the user can format the text and export it.


Ok, but export it in which format? The standard for formatted text is HTML or RTF so to which one do you want to convert it?
Nicola Gervasi
sintpro.com
SAN Partner
ngervasi
 
Posts: 1485
Joined: Tue Dec 21, 2004 12:47 pm
Location: Arezzo, Italy

Re: convert html to text

Postby Joas » Mon Nov 10, 2008 2:50 pm

Hmmm, I don't really get the problem then. If you want to keep the formatting, why can't you just use the html from the dataprovider?
Joas de Haan
Yield Software Development
Need help on your project? yieldsd.com
User avatar
Joas
Site Admin
 
Posts: 842
Joined: Mon Mar 20, 2006 4:07 pm
Location: Leusden, NL

Re: convert html to text

Postby irenem » Mon Nov 10, 2008 3:07 pm

I use the wordplugin from it2b. If I replace the bookmark with the content of the html-area I get the whole code.
Code: Select all
<html>
  <head>

  </head>
  <body>
    <p style="margin-top: 0">
      Zandweg 69 B
    </p>
    <p style="margin-top: 0">
      3454 JW <b>De Meern</b>
    </p>
  </body>
</html>


What I want to see is this:

zandweg 69b
3454JW De Meern
Irene Meyer

Version: 6.0.5
Java version 1.6.0_29
Mac OS X Version 10.7.3
User avatar
irenem
 
Posts: 279
Joined: Tue Aug 28, 2007 2:09 pm
Location: Netherlands

Re: convert html to text

Postby Karel Broer » Mon Nov 10, 2008 5:43 pm

if it's only to modify (some) text to bold, you can use plugins.it2be_word.toggleBold() for that with the Word plug.
I'dd say use the getAsPlainText() function and apply plugins.it2be_word.toggleBold() .
Karel Broer
ServoyCamp - http://www.servoycamp.com
User avatar
Karel Broer
 
Posts: 779
Joined: Mon May 03, 2004 12:49 am
Location: Doetinchem

Re: convert html to text

Postby IT2Be » Mon Nov 10, 2008 11:50 pm

Which version do you use?

If it is the IT2BE Word Plug-in for Servoy 4 Eclipse the by Karel suggested methods will not work due to new libraries.
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Re: convert html to text

Postby irenem » Tue Nov 11, 2008 12:07 am

Hi Marcel,

The version for Servoy 4 is the version I use. Is there any other way to do this? Or will it be possible in the future?
Irene Meyer

Version: 6.0.5
Java version 1.6.0_29
Mac OS X Version 10.7.3
User avatar
irenem
 
Posts: 279
Joined: Tue Aug 28, 2007 2:09 pm
Location: Netherlands

Re: convert html to text

Postby IT2Be » Tue Nov 11, 2008 12:33 am

See my reply on our forum irene: http://www.it2be.com/index.php/forum?ta ... 1433#p1433

I see several ways to solve this, depending on what you need to do.
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany


Return to Methods

Who is online

Users browsing this forum: No registered users and 3 guests