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
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