May 11, 2007

Antialiased Printing from Java : Solution

Filed under: Java — khangharoth @ 2:20 pm

In continuation to the last post ,I would like to share what i understood till now.

With Java if you do component printing that is you right code in print method of Component implementing Printable interface,with the help of commands like

g2.drawLine(x1, y1, x2, y2);

g2.drawRect(x, y, width, height);

than you will get anti aliased printing  .That is no jagged effect,a very smooth print.But if you will give print of a Raster data say PNG or JPEG image ,in this case you will use something like

g2d.drawImage(image, 0, 0, width, heigth, this);

than chances are that you will get jagged print .

The difference in both these are  :1) In first case you are telling that you want to draw a line and you provide two points.Your java call is taken up by OS specific printerJob,on windows it will be Win32PrinterJob.Now this printerJob interacts with the driver of the printer to convert into a specific printer understandable vector format.

In host machine,printer driver is the interface between the printer and your application. So to print your application should be able to locate the plotter driver and dump all the data either from GDI buffer or Opengl buffer for printing.

So the crux is ,you just give instruction about how to draw in Java2D and it will be passed on to GDI libraries of Windows platform and than from printer Driver interface to printer.So all the work of maintaining quality is done by Windows.

More on Java printing will come in subsequent blogs!


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at

%d bloggers like this: