Article View: borland.public.jbuilder.java.language
Article #17913Re: printing multipage
From: John P. McGrath
Date: Sun, 20 Sep 1998 00:00
Date: Sun, 20 Sep 1998 00:00
37 lines
1647 bytes
1647 bytes
Martin Fuente <sistemas@gbreuer.com.ar> wrote:
> I am traying to print multipage and the number of pages is
> variable. What is the best way to do that?
> I want to generate a big canvas with all i want to print,
> and then with the printjob graphics print rectangles at
> the same size of the page. This is correct? How can i do??
You need to get a separate Graphics object using the PrintJob
getGraphics() method for each page you want to print.
If you have a large canvas and you want to subdivide it into
pages. I believe you would use the Graphics translate() method
to adjust the origin of the Graphics context, and the clipRect()
method to clip the printing area.
I have done similar things, but not this exactly, so I am not
positive that this will work, but I believe it is the right
approach. I may have the signs mixed up.
/**
** Print part of a component.
*/
public void printPage( PrintJob job, Component c, Rectangle r ) {
Graphics g = job.getGraphics();
g.translate( -r.x, -r.y );
g.clipRect( 0, 0, r.width, r.height );
c.paint( g );
g.dispose();
}
--
Regards,
John P. McGrath
<mcgrath@enter.net>
<jpm@nscs.fast.net>
Technical Details
Message-ID:
<MPG.106eb17c4a83bf289896b5@forums.inprise.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<6tun0h$br46@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,3d594cd77866910c X-Google-Attributes: gidf74b3,public From: mcgrath@enter.net (John P. McGrath) Subject: Re: printing multipage Date: 1998/09/20 Message-ID: <MPG.106eb17c4a83bf289896b5@forums.inprise.com> X-Deja-AN: 392959755 References: <6tun0h$br46@forums.borland.com> Organization: Software Consulting Services Newsgroups: borland.public.jbuilder.java.language