我希望获得在我的程序中打印的总页数。我正在使用java.awt.Desktop类。这是我的打印部分代码 -
public class PrintJob {
public static void print(String str) {
try {
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
desktop.print(new File(str));
} catch (IOException ioe) {
//ioe.printStackTrace();
JOptionPane.showMessageDialog(null, "Invalid file type.");
}
}
}
我希望获得要打印的总页数。我该怎么做?