Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing frames and scaling images

Status
Not open for further replies.

RobRutter

Programmer
Nov 19, 2002
1
GB
I have an AWT frame that I am printing. It is bigger than an A4 page and it gets truncated when it is printed.

Does anyone know how I can scale down the frame prior to printing?

I can print it using the code snippet below.

....

class PrintData {
public PrintJob pj;
public int pageWidth, pageHeight;
Image image;

PrintData(String jobName) {
// ImageObserver observer = null;
pj = getToolkit().getPrintJob(EnquiriesFrame.this, jobName, null);
if (pj != null) {
pageWidth = pj.getPageDimension().width;
pageHeight = pj.getPageDimension().height;
Graphics pg = pj.getGraphics();
if (pg != null) {
EnquiriesFrame.this.printComponents(pg);
pg.dispose();
}
}
}
void end() {
pj.end();
}
}

void buttonPrint_actionPerformed(ActionEvent e) {
PrintData pd = new PrintData("Stock print");
if (pd == null) {
return;
}
pd.end();
}
.....

Having read over the java help documentation I am aware that image objects can be scaled down in size. But what I cannot do is associate an image with the frame.

Thanks for any help

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top