The hard part is that JEditorPane only accepts strings or URLs. One way is to read the contents of the file into a StringBuilder, then call its toString() method. The easier way is to convert a File into a URL:
Although it can't handle objects like images or embedded Office documents, simple text including the format should not be a problem.
Joined: Oct 08, 2008
No method like pane.print();
Only pane.print(graphics); is available. How to use this please assist me
The print methods have only been introduced in Java 6. I suggest you upgrade to that version.
Alternatively you could implement your own Printable implementation:
This is a very naive approach implementation though, since it doesn't paginate at all - it will try to print everything on a single page.
In a proper solution, you need to calculate on which part of the pane to print based on the page. Hint: use graphics.translate() for that.