[Opensource] Printing using 2D graphics

David Herron davidh at 7gen.com
Thu Apr 17 11:43:15 PDT 2003


Jeff,

Maybe the JFreeReport package is what you're looking for.  (There's also
JasperReports that does similar things).  Both are open source projects
that you can find by doing a search.

You might look at JEditorPane along with HTML to do the formatting.  Since
it is a lightweight Swing component, it can be rendered to a BufferedImage
in Headless mode.

a) run Java with -Djava.awt.headless=true
  This blocks off all attempts to reach a graphics device, and does
  so in a programmer-friendly manner so that a programmer can easily
  write graphics oriented code and have the code easily and clearly know
  whether it's in a GUI or off-screen environment.

b) make a BufferedImage

c) get it's Graphics

d) make a component hierarchy including JEditorPane.  Fill it with
  your HTML.  Call paint(graphics).

e) The BufferedImage then has whatever-you-want rendered into it, and
  you can do whatever you want with it.

Have fun,

	David Herron



On Wed, 16 Apr 2003, Jeff Johnson wrote:

> I have a java app that generates a text string from a users input.  upon
> completing the input, the app displays the text (formatted with the
> appropriate escape codes ( \n ),etc) in a starOffice document, and it
> can be printed from there.  Now I'm trying write the app to insert a
> logo (picture.bmp)  and then the text string  into the document, so that
> the app can print the letter on letterhead..
>
> After numerous failures, the only recourse seems to be java 2D.  As I
> read the 2d tutorial, it seems that you can insert a graphic and then
> print a text string, but it seems cumbersome, and I have a feeling that
> the text string will have to be formatted to look acceptable.
>  Additionally, with 2D it seems that the user can't have a look like he
> could if it was all displayed in a S/O template(I think).  Does anyone
> have any experience with 2D who would like to offer some advice?  Or is
> there a better method, or better yet, does anyone know if S/O can do it
> and I am just dumb for not seeing it?....J Johnson
>
> _______________________________________________
> Opensource mailing list
> Opensource at jcorporate.com
> http://mail.jcorporate.com/mailman/listinfo/opensource
> Archives: http://mail.jcorporate.com/pipermail/opensource/
>




More information about the Opensource mailing list