PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 2024 → [WM23] RTF
[WM23] RTF
Débuté par ARV, 17 oct. 2018 19:31 - 3 réponses
Membre enregistré
498 messages
Popularité : +8 (8 votes)
Posté le 17 octobre 2018 - 19:31
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
Membre enregistré
794 messages
Popularité : +40 (42 votes)
Posté le 18 octobre 2018 - 15:27
Hi. That code depends on the Java Swing libraries to work, and Swing cannot be used on Android.

Rubén
Membre enregistré
498 messages
Popularité : +8 (8 votes)
Posté le 18 octobre 2018 - 17:07
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 modifié, 18 octobre 2018 - 17:07
Membre enregistré
794 messages
Popularité : +40 (42 votes)