}
private static void printHeadless(ComboFrame frame, Document doc) {
// The Printable:
final Engine engine = doc.getEngine();
// The layout info:
PrintLayoutModel layout = doc.getPrintLayout();
// The Engine's layout sub-info:
final PrintSettings settings = layout.getPrintSettings();
PrinterLayer printer = Platform.getPlatform().getPrinterLayer();
// The PageFormat:
printer.setPageFormat(layout.getPageFormat());
final PageFormat format = printer.getPageFormat();
// Make up a name for the print job:
String jobName;
File file = doc.getFile();
if (file != null) {
jobName = file.getName();
}
else {
ImageMetadata meta = doc.getMetadata();
jobName = meta.getFile().getName();
}
printer.setJobName(jobName);
boolean doPrint = printer.printDialog();
if (doPrint) {
ProgressDialog dialog = Platform.getPlatform().getProgressDialog();
ProgressThread thread = new ProgressThread(dialog) {
public void run() {
try {
engine.print(this, format, settings);
}
catch (PrinterException e) {
throw new RuntimeException(e);
}
}
public void cancel() {
engine.cancelPrint();
}
};
dialog.showProgress(
frame, thread, LOCALE.get("PrintingMessage"), 0, 0, true
);