0

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?

5
  • 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. Commented Jun 25, 2009 at 19:53
  • 1
    I 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. Commented Jun 25, 2009 at 19:58
  • 1
    Is this any different than rendering the HTML+CSS? Commented Jun 25, 2009 at 20:09
  • its html css styled files converting to rtf kind of format Commented 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. Commented Jun 26, 2009 at 12:01

3 Answers 3

1

I'd do the following:

  1. At first use JTidy to convert HTML to valid XHTML
  2. 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

Sign up to request clarification or add additional context in comments.

3 Comments

An XSLT won't take account of the HTML document's CSS styling. (Or will it? I may be wrong.)
@Andrew Duffy: Well if it does not, it's a bad xslt. Although there my be a problem with external css, you can download that and insert it inline into the document to transform.
@Andrew Duffy: Of course you are right, it won't, cause the css is no xml... Stupid me... I'll go get some rest ;-)
1

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

its have to be batch convector something that needs to process allots of files
The link points to a number of headless transformers -- you may want to check those out.
0

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?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.