cancel
Showing results for 
Search instead for 
Did you mean: 

Convert rtf text to plain text

5,837

Is there any function in sybase to convert rtf text to plain text. We use SA17

Accepted Solutions (1)

Accepted Solutions (1)

MarkCulp
Participant

No, SQL Anywhere does not have any functions to convert documents from one format to another. You will need to use some external application to do this type of operation.

0 Kudos

Ok, thanks for your reply. I have googlat and tried to find some help but it seemed to be sparse. Thought if I could do it with a procedure or reached. Have you done it lately with any external application?

chris_keating
Product and Topic Expert
Product and Topic Expert

Depending on the expected content of the rich text, there are several examples posted on the internet that use regular expressions that can do this for most rich text.

There are also several examples using Java and C# (.NET CLR). The C# version uses a MS RichTextBox control text property which contains the text of the control excluding the rich text format codes. You could then use the external environment feature to access the Java or .NET CLR code like a procedure.

0 Kudos

I would rather try to use SA to solve this. Where can I find an example using regular expressions? Or do you have any examples?

0 Kudos

Mark, Do you have any example to solve this with regular expressions?

Breck_Carter
Participant
0 Kudos

FYI here is one version of the RTF specifications... are you sure you want regular expressions to deal with that?

0 Kudos

Thanks! I'm open to other suggestions if they work with SA17.

chris_keating
Product and Topic Expert
Product and Topic Expert

As Breck clarified with the RTF spec and I hinted in my initial response, this will be difficult to achieve with regular expressions except in some specific cases. Most of the threads that I read on line on this topic suggested that a parser would be the only real solution to this. I proposed taking advantage of java or .NET as they have existing objects that can do that heavy lifting and can be used as an external environment in SQL Anywhere.

Vlad
Product and Topic Expert
Product and Topic Expert

Hm, I see a good option: textutil (BSD, MacOS): http://osxdaily.com/2014/02/20/batch-convert-docx-to-txt-mac/ It is not to find a console library that converts from RTF to TXT (to HTML is possible, but not to TXT).
I'd better close this question as "use 3rd-party tools".

Answers (0)