I know this is a little off the topic. However if any one can help, I would
be very appreciated.
Try to print a page from my applet use following codes.
However, setImageableArea() seems not working as I expected. When the paper
is print out, the size of Imageable area is always in default.

thanks in advance.

public int print (Graphics g, PageFormat pageFormat, int page) {

      int i;
      Graphics2D g2d;
      Line2D.Double line = new Line2D.Double ();

       Paper myPaper = pageFormat.getPaper();

                 myPaper.setImageableArea(36.0,18.0,540,756);
         //--- Create the Graphics2D object
       pageFormat.setPaper(myPaper);
      //--- Validate the page number, we only print the first page
      if (page == 0) {

         //--- Create a graphic2D object a set the default parameters
         g2d = (Graphics2D) g;
         g2d.setColor (Color.black);

         //--- Translate the origin to be (0,0)
         g2d.translate (pageFormat.getImageableX (),
pageFormat.getImageableY ());

         //--- Print the vertical lines
         for (i = 0; i < pageFormat.getWidth (); i += INCH / 2) {
            line.setLine (i, 0, i, pageFormat.getHeight ());
            g2d.draw (line);
         }

         //--- Print the horizontal lines
         for (i = 0; i < pageFormat.getHeight (); i += INCH / 2) {
            line.setLine (0, i, pageFormat.getWidth (), i);
            g2d.draw (line);
         }

         return (PAGE_EXISTS);
      }
      else
         return (NO_SUCH_PAGE);
   }

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to