Houssam Badri
Houssam Badri

Reputation: 2509

Get rid of Prompt Dialog when printing with Java

In this piece of code:

//Staff
pf.setOrientation(PageFormat.LANDSCAPE);
pj.setPrintable(graphComponent);
try {
    pj.print();  // This is the function in question !!
} catch (PrinterException e2) {
    System.out.println(e2);
}
//Staff

The function print of the job printer, leads you to

Printing promt

What I want, is that I give a default name to the file (printing result) without having that prompt. How can I change that code to get that?

Upvotes: 0

Views: 82

Answers (1)

Gabriel Ruiu
Gabriel Ruiu

Reputation: 2803

Assuming that your pj is a PrinterJob instance, try calling

pj.setJobName("defaultname.pdf");

Upvotes: 1

Related Questions