HTML to RTF

Hi all
I rename an HTML to RTF and if I use WORD DOC I see what I want to see.
If I use WORD PAD I see the HTML code.That's bad.
Any usefull idea with xsl or sort of?
Regards

You can do as follow:
HTMLEditorKit htmlEditorKit = new HTMLEditorKit() ;
RTFEditorKit rtfEditorKit = new RTFEditorKit() ;
Reader in = new FileReader("theHTMLFile.html") ;
Document doc = htmlEditorKit.createDefaultDocument() ;
htmlEditorKit.read(in, doc, 0) ;
in.close() ;
OutputStream out = new FileOutputStream("theRTFFile.rtf") ;
rtfEditorKit.write(out, doc, 0, doc.getLength()) ;
out.close() ;That will probably only work with simple text without any complex formatting and without graphics...
Yannick

Similar Messages

  • How do I save a file as an unformatted txt file instead of html or rtf?

    How do I save a file as an unformatted txt file instead of html or rtf?

    Use menu Image>Image Size in the image size dialog uncheck Resample and enter 300 in the resolution field and click OK.  Note no Pixels are changed only the resolution setting get changed.  The use Menu Fils>Save As in the save as dialog use the file type pull down and select Tiff then click Save
    In the Tiff Option Dialog in the Image Compression  section set None The click OK.

  • Problem reading html and rtf emails

    When I send emails from my pc to my iPhone 5 in html or rtf format they are unreadable as all of the coding instructions are also included in the text when it appears on screen. This was never a problem with my iPhone 4 so I am not sure what has changed. I have a business contact who has had similar problems in the recent past with my emails so I know it is not just me.
    I have tried sending html emails from other pc's in the office to my phone and they are all readable so perhaps it is something in the set up of my pc that is causing this issue. As my office is changing over to iPhone 5's does anybody have any solution to what will become a very annoyinmg problem.
    Obviously I could send all of my emails in plain text but that doesn't really work for what I need to send, logo's / graphics etc.

    Hi
    The best way to organize data and images to get them next to each other is to use a table (no borders) in your RTF template. Create a two celled table and drop the image into one and the text next to it.
    Regards
    Tim

  • Printing XLS, HTML, or RTF using Apache FOP

    Hi,
    Is it possible to print XLS, HTML, or RTF reports using Apache FOP? If not, is there another open source or free print server that will do this?
    Thank you.
    Martin

    Hello,
    >>
    Your going to want to study the Cocoon sitemap concept to see how to pipeline the xml and xsl to the right output.
    >>
    To get this working correctly you need to understand the Cocoon sitemap concept and how to read data out of the XML file your posting in order to pipeline it to the right rendering format. It's pretty much a hands on affair so it depends on what your trying to do, sorry there is no easier way to do it.
    In a future versions it will be easier to do this as you will be able to select specific end points per report.
    Regards,
    Carl
    blog : http://carlback.blogspot.com/
    apex examples : http://apex.oracle.com/pls/otn/f?p=11933:5

  • Open HTML and RTF in JEditorPane !!

    Hello,
    Is it possible to use JEditorPane to open a HTML file and then save it as RTF?
    And open a RTF file and save it as HTML ???
    Eric

    I tried. When the HTML or RTF contains TABLE, both will not recognize it. Is there any problem.
    I mean if the HTML contains TABLE, when I tried to write it to RTF, it will omit the table format. In the contrast, if the RTF contains the TABLE format, when I write the RTF to HTML, it also omits the table format.
    Eric

  • HTML to RTF Convertor

    I've got a number of HTML formatted datafields that users have entered using the APEX text editors (FCK).
    I would like to integrate those fields with a report but the report if not interpreting the HTML very well. As such I'd actually like to convert the HTML to RTF.
    I see a number of commercial DLL's exist for doing this within end applications.
    I'd prefer to actually do this conversion at the database side - has anyone done anything similar? Or have any suggestions for an approach?
    Thanks,
    Scott

    I'm working with Crystal Reports - the report must be customer quality. And the issue surrounds the fact that Crystal only supports limited HTML tags (see http://technicalsupport.businessobjects.com/KanisaSupportSite/search.do?cmd=displayKC&docType=kc&externalId=c2014842&sliceId=&dialogID=9876280&stateId=1%200%209874388)
    But it's RTF support is a lot better, hence the desire to convert the HTML to RTF.

  • Textutil html to rtf vs. TextEdit

    I have noticed what looks like a bug in either TextEdit of textutil, but not sure where it is. When I convert html to RTF using the textutil command, the resulting file opens in TextEdit with black text on a black background. It looks a lot like the Safari email creation bug they just fixed with 5.0.1 (yes, I installed it).
    Opening the resulting file in TexEdit Plus, Pages, OmniOutliner, Word, OpenOffice all display the file without the black background. I will be reporting it to AppleCare tomorrow.
    What I'm not sure about and thought I'd ask here is: do you think the RTF code output from textutil is wrong, or TextEdit is displaying the file incorrectly. Since all the other programs display it correctly, I am tempted to implicate TextEdit, but maybe they just ignore the "background" instruction that seems to be placed by textutil (see below).
    If i create a document in TextEdit and save to disk, I get the following code:
    {\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf320
    {\fonttbl\f0\fswiss\fcharset0 Helvetica;}
    {\colortbl;\red255\green255\blue255;}
    \margl1440\margr1440\vieww9000\viewh8400\viewkind0
    \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx792 0\tx8640\ql\qnatural\pardirnatural
    \f0\fs24 \cf0 Hello World}
    If I create a barebones html document (see script below) and convert html to RTF using textutil, I get:
    {\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf320
    {\fonttbl\f0\froman\fcharset0 Times-Roman;}
    {\colortbl;\red255\green255\blue255;}
    \deftab720
    {\*\background {\shp{\*\shpinst\shpleft0\shptop0\shpright0\shpbottom0\shpfhdr0\shpbxmargin\shp bymargin\shpwr0\shpwrk0\shpfblwtxt1\shpz0\shplid1025{\sp{\sn shapeType}{\sv 1}}{\sp{\sn fFlipH}{\sv 0}}{\sp{\sn fFlipV}{\sv 0}}{\sp{\sn fillColor}{\sv 0}}{\sp{\sn fFilled}{\sv 1}}{\sp{\sn lineWidth}{\sv 0}}{\sp{\sn fLine}{\sv 0}}{\sp{\sn bWMode}{\sv 9}}{\sp{\sn fBackground}{\sv 1}}}}}
    \pard\pardeftab720\ql\qnatural
    \f0\fs24 \cf0 Hello World}
    What seems to be the big difference is the "background" code -- If I remove it, all is well. It apparently specifies the background for the document, and in this case tells it to be a rectangular shape with various parameters, but if I try changing the shape or fill color it doesn't seem to make a difference.
    So I guess the question is why textutil is putting that code in there, and why it screws up TextEdit's display...
    (the spec for the parameters is here: http://www.biblioscape.com/rtf15_spec.htm )
    Here's an AppleScript that re-creates the problem:
    set oFile to "/Users/username/Desktop/oFile.html"
    set strHTML to "<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/></head><body>Hello World</body>"
    try
    set fDesc to open for access oFile with write permission
    write strHTML to fDesc as «class utf8»
    close access fDesc
    on error
    try
    close access fDesc
    return strText
    end try
    end try
    set strCommand to "textutil -convert rtf " & (quoted form of (POSIX path of oFile))
    set strResult to (do shell script strCommand)

    If you want to report this issue to Apple's engineering, send a bug report or an enhancement request via its Bug Reporter system. To do this, join the Mac Developer Program—it's free and available for all Mac users and gets you a look at some development software. Since you already have an Apple username/ID, use that. Once a member, go to Apple BugReporter and file your bug report or enhancement request. The nice thing with this procedure is that you get a response and a follow-up number; thus, starting a dialog with engineering

  • HTML to RTF conversion

    Hello. I am trying to convert a simple html string and produce a rtf file using the HTMLEditorKit and RTFEditorKit. I have already found some topics which cover the process and their authors warn that the output RTF will not contain images and tables. But what strikes me is that i can't even get new lines and paragraphs in the RTF-file. Here is the example code. The output RTF document contains just a single line of text. Thank you in advance!
    import java.io.*;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.DefaultStyledDocument;
    import javax.swing.text.html.HTMLDocument;
    import javax.swing.text.rtf.RTFEditorKit;
    import javax.swing.text.html.HTMLEditorKit;
    public class MainController {
         private DefaultStyledDocument htmlDoc;
         private HTMLEditorKit htmlKit;
         private RTFEditorKit rtfKit;
         public MainController() {
              htmlDoc = new HTMLDocument();
              htmlKit = new HTMLEditorKit();
              rtfKit = new RTFEditorKit();
         private void convert(String strText) {
              StringReader reader = new StringReader(strText);
              try {
                   htmlKit.read(reader, htmlDoc, 0);
                   FileOutputStream f = new FileOutputStream("rtfdoc.rtf");
                   rtfKit.write(
                        f,
                        htmlDoc,
                        0,
                        htmlDoc.getLength());
                   JEditorPane pane = new JEditorPane("text/html", strText);
                   JFrame frame = new JFrame();
                   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   frame.getContentPane().add(pane);
                   frame.setSize(300,300);
                   frame.show();
                   Thread.sleep(5000);
              catch (IOException ie) {
              catch (BadLocationException ble) {
              } catch (InterruptedException e) {
                   e.printStackTrace();
         public static void main(String args[]) {
              MainController conv = new MainController();
              String strRTF =
                        "<html><head><p class=default><span style=\"color: #000000\">Test </span><span style=\"color: #000000\"><b>line</b> </span><span style=\"color: #000000\"><i>1</i> </span></p>" +
                        "<p class=default><span style=\"color: #000000\">Test </span><span style=\"color: #000000\"><b>line</b> </span><span style=\"color: #000000\"><i>2</i> </span></p></head></html>";
              conv.convert(strRTF);
              System.exit(0);
    }

    When you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read and prevents accidental markup from array indices like [i].

  • Convert HTML to RTF

    Hi,
    Is there a way to build a utility program which accepts HTML file and converts it to RTF Format. I do not wish to install or purchase any 3rd party software. Please suggest.
    Regards,
    Murali

    Write or find an HTML parser; define the required mapping from input to output; and implement it. There is no RTF library built into Java so you will have to find or write that too.

  • Use JEditorPane to display HTML and RTF ?

    Hello,
    Is it possible to use JEditorPane to open a HTML file and then save it as RTF?
    And open a RTF file and save it as HTML ???
    Eric

    bump...
    has anyone a solution to this?
    I have a form that allows users to add raw HTML code. Now I want to display the formatted version in a report but the tags show in the report instead...any suggestions?
    regards
    Paul P

  • Dynamically Generated HTML/PDF/RTF?

    Hi guys,
    This is similar to something I asked recently, but I've got a better idea of what I need and how to ask. I'm still fairly novice at programming, espeically applets.
    I'm working on an applet for an educational purpose that will generate an array of study items...probably 30-50, I haven't decided on the size yet. It's for foreign language study, and the items are foreign phonetic characters, no more than 3 per item. I'd like to output them in a print-ready format, probably essentially a grid, with some space for the student to write their answer next to or under it. I've seen some free libraries out there that can generate pdf, rtf, and HTML, most notably the iText libraries.
    I really want to do this as an applet. So my question is, how would this, or another library that one of you knows that would be better, be implemented? Would the output be a file on the server? Is there a way to make it generate the file to the users local cache or something, or give them an option to download it without it going on a server, since it is randomly generated and not uniform for other users? (I assume that would require making it a signed applet?)
    Any help you can give would be really appreciated.
    Colin

    cosmic_cow wrote:
    Okay, but this would work very well as a web application.What's a good resource for learning to work with them as opposed to applets? (Told you I'm a novice! ) Well, if you're a novice it might be better to concentrate on the regular Java stuff and sure, applets too.
    Then if you feel interested in Java EE and Web Applications and Databases and what not, you can check out this to see what Enterprise Java consists of.

  • How to display an HTML or RTF or PDF in flash

    Hi all,
    Is there any way to display a simple html document inside an
    swf?
    Note that the html will contain text, bullets, tables and
    bookmarks, but no images or links.
    Thanks in advance

    Try a textarea component.

  • HTML Email saved as MSG opens as RTF Email when Exchange Cached mode is OFF

    Hello,
    i have the following problem:
    In an Exchange 2013 environment each time i open a HTML email and save it to disk as a MSG file (Unicode or non Unicode) i get a MSG file with an RTF Body. This only happens when Exchange Cached mode is turend OFF. I tested this with Outlook 2010 and Outlook
    2013 with no 3rd Party Addins installed. Any idea?
    Regards
    Thorsten
    Best Regards/Viele Grüße Thorsten

    I've found this information from our internal channel.
    In some case, when you need to convert MIME e-mail with HTML body into .MSG file. For that, HTML must be converted into RTF.
    Outlook Converter provides basic means of such conversion (which can be suitable in most cases), and lets you use any external converter for high-quality HTML-to-RTF conversion. Although Outlook can display .MSG files which have HTML
    body and no RTF body, the problem occurs when you try to forward or reply such e-mail. For this to succeed, the original message must have RTF body as well.
    So, please check whether the message you've dragged onto desktop is MIME message. This might be the root, however, it
    still doesn't explain why it only occurs in specific circumstances (Exchange online mode only).
    Feel free to post back. Thanks.
    Cheers,
    Tony Chen
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please contact
    [email protected]

  • Convert doc to rtf or doc to html

    Is there any approach to convert the doc files to html or rtf format? The appache poi just provides the read facilities not the converting facilities.
    It's not the problem to convert from rtf to html using XSL transformation.
    But what about doc to rtf. Probably there already written solutions using poi or smth. else?

    Two projects that spring to mind are Apache POI and Apache FOP.
    POI:
    http://jakarta.apache.org/poi/index.html
    FOP:
    http://xmlgraphics.apache.org/fop/
    Either way, you are in for some tough development if you want to do this using Java, and you might want to consider switch to a more suitable platform such as .NET. Word documents are highly microsoft specific so you will want to use a microsoft platform to work with them for the least amount of headaches and risks.

  • Plug-ins for Previewing files such as .rtf, .swf, and .html in Finder?

    Are there plug-ins which would allow files such as .html and .rtf to display details of their content within the Finder's Preview pane, in a way similar to the way it is possible to preview .pdf, .txt, and .jpg files?
    thanks

    No, but any text editor can display html and rtf files, for example, TextEdit in your Utilities folder.

Maybe you are looking for