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

Similar Messages

  • Textutil html conversion broken after Safari 3 update?

    I have some scripts that use textutil to convert html files to rtfs. I tried one today & it didn't work -- tried running textutil filename.html -convert rtf from the command line, and after an unusually long wait I eventually got the message "Error reading filename.html"
    I can't remember the last time I used these scripts but it's been a few weeks, so I'm thinking the culprit is Safari 3 / webkit....
    Has anyone else seen this problem / got an idea for a fix?
    thanks
    Derick

    Hi, Derick
    I'm noticing the same problem, but if I supply the full path to the file textutil works fine. For example:
    textutil ~/Sites/new.html -convert rtf
    In this case, I'm quickly supplied with new.rtf in the Sites directory. However,
    textutil new.html -convert rtf
    doesn't work even if I'm in the proper directory.
    I'm not sure what to make of this. Perhaps, if textutil decides a file may be html, it decides to try and look up the file through the webserver even if it's a local file...?
    Caleb
    iMac g3 400MHz    

  • 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

  • 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

  • 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.

  • 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.

  • How to display russian from a an html file created in textedit?

    I have created an html page in textedit which contains some russian text, how can i get safari to display this text properly?? In my textedit i used plain text but for some reason it comes out all starange in safari....

    Safari is using the wrong encoding.  Normally you would go to View > Text Encoding in your browser and try the different ones for Cyrillic until the display is correct.
    When you make an html page, you are always supposed include code which tells the browser what encoding to use.  Have you done that?  I would recommend that when you save in TextEdit you use UTF-8 and also put that in the html code.
    http://www.w3schools.com/tags/att_meta_charset.asp

  • 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.

  • 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

  • Looking for a sort of "activity code" in transactions ME51N/ME52N/ME53N

    Hi all experts, got an - I hope - interesting question to ask you. I have an user exit that is executed on every step done in creation/modify of a Purchase requisition. In this code (custom), executed from the transactions ME51(n)/ME52(n) and ME53(n)

  • Touch screen ghost clicks

    Hello, I have a Touchsmart notebook that seems to have  a mind of it own. Occasionally, once in 2 weeks almost, the touch screen picks a spot ( the same spot ) and keeps selecting it every 5-10 seconds. When this happen you cannot navigate or even sh

  • BAPI for assing source of supply for purchase requisitions

    Hi, can any one let me know if there is any bapi or function module to assing source of supply for purchase requisitions.  Points will be given regards, siva prasad.

  • Ios 7.0.6 icon gray installation AIR 4.0.0.1628

    Problem Description: when i try to install an app in ios 7.0.6 the icon remains gray and does not install Steps to Reproduce: update your ios device to 7.0.6 and try to install an app created with adobe air sdk, i have already tried with AIR 4.0.0.16

  • Help with Calculate Script

      The script below gives me The pattern: date{EEEE, MMMM DD, YYYY} ( DateWeekEnding.rawValue==null) Calculate Event for TextField_A: if then  $.rawValue = ""else Num2Date(Date2Num( DateWeekEnding.formattedValue, DateFmt(1)) +1, DateFmt(4)) endif Date