PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV Mobile 2024 → [WM23] RTF
[WM23] RTF
Started by ARV, Oct., 17 2018 7:31 PM - 3 replies
Registered member
498 messages
Popularité : +8 (8 votes)
Posted on October, 17 2018 - 7:31 PM
Hi all

I want to convert RTF to text or HTML I found some thread on the windev forum but I can't get it working
they said that I use this java code on windev
https://www.codeproject.com/Tips/136483/Java-How-to-convert-RTF-into-HTML

for obvious reson I can't copy and paste the exact same code on windev, I do some code for addapting on windev but it doesn't work.
the classes the code call it launch me errors that windev can't find them I don't know what to import I search to import but I can't get it work.

this is my code

import java.io.*;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Desktop;
import java.awt.EventQueue;
import java.awt.Insets;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.EventObject;
import javax.swing.AbstractCellEditor;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.text.AttributeSet;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLDocument;
public static void prueba(String rtf) throws IOException {
JEditorPane p = new JEditorPane();
p.setContentType("text/rtf");
EditorKit kitRtf = p.getEditorKitForContentType("text/rtf");
try {
kitRtf.read(rtf, p.getDocument(), 0);
kitRtf = null;
EditorKit kitHtml = p.getEditorKitForContentType("text/html");
Writer writer = new StringWriter();
kitHtml.write(writer, p.getDocument(), 0, p.getDocument().getLength());
callWLProcedure_String("ProcedureTest",writer.toString());
//return writer.toString();
} catch (BadLocationException e) {
e.printStackTrace();
}
//return null;
}


someone Know how to solve it?
thanks!

--
Best Regards
ARV
Registered member
794 messages
Popularité : +40 (42 votes)
Posted on October, 18 2018 - 3:27 PM
Hi. That code depends on the Java Swing libraries to work, and Swing cannot be used on Android.

Rubén
Registered member
498 messages
Popularité : +8 (8 votes)
Posted on October, 18 2018 - 5:07 PM
Hi Rubén

Oh come on!...
so what can I do now?
My text it's on RTF on the DB and I need to show it on android...

thanks for the reply!

--
Best Regards
ARV
Message modified, October, 18 2018 - 5:07 PM
Registered member
794 messages
Popularité : +40 (42 votes)