i need to understand html + css files and convert it to somthing like rtf layot in java now i understand i need somekind of html parser but what i need to do from there ? how can i implement html-css convertor ? is there somekind of patern or method for such jobs?
-
What do you mean by the html-css converter? For most cases, you are better off using an editor that supports both file types for conversion.dborba– dborba2009-06-25 19:53:17 +00:00Commented Jun 25, 2009 at 19:53
-
1I don't think he/she means converting from html to css, but rather converting css-styled html to rtf. At least that's how I read it.wkf– wkf2009-06-25 19:58:08 +00:00Commented Jun 25, 2009 at 19:58
-
1Is this any different than rendering the HTML+CSS?Grzegorz Oledzki– Grzegorz Oledzki2009-06-25 20:09:46 +00:00Commented Jun 25, 2009 at 20:09
-
its html css styled files converting to rtf kind of formatuser63898– user638982009-06-26 05:33:13 +00:00Commented Jun 26, 2009 at 5:33
-
If possible, use the Google translator's web-page translation feature if you don't need 100% correct translation. Otherwise go for the other methods suggested by others.akarnokd– akarnokd2009-06-26 12:01:53 +00:00Commented Jun 26, 2009 at 12:01
3 Answers
I'd do the following:
- At first use JTidy to convert HTML to valid XHTML
- Apply an XSLT to convert to RTF using an XML library like Saxon or Xerces
Note: although I didn't find an xsl file for that conversion directly I'm sure there is one anywhere
3 Comments
You should check out HTMLEditorKit. It provides some support for CSS rendering. There is also an RTFEditorKit for writing, although it is not entirely reliable (last I checked, several years ago).
Is there a reason you need to use Java instead of just loading the HTML in Word (or some other editor) and saving it as RTF? Also check this W3C link.
2 Comments
There is the The Flying Saucer Project that let you render XHTML to PDF. Maybe that could be used instead of RTF or the resulting PDF could be converted to RTF?