📄 e715. listening for print job attribute changes.txt
字号:
Status changes that are common to all print jobs are delivered through a print job listener; see e714 Listening for Print Job Status Changes. However, if a print service supports a status that is not supported by the print job listener (e.g., JobMediaSheetsCompleted), it delivers status changes through a print job attribute listener.
// Create the print job
DocPrintJob job = service.createPrintJob();
PrintJobAttributeSet set = new HashPrintJobAttributeSet(job.getAttributes());
set.add(new JobMediaSheetsCompleted(0));
job.addPrintJobAttributeListener(new MyPrintJobAttributeListener(), set);
class MyPrintJobAttributeListener implements PrintJobAttributeListener {
public void attributeUpdate(PrintJobAttributeEvent pjae) {
// Get the set of attributes that have changed
Attribute[] attrs = pjae.getAttributes().toArray();
for (int i=0; i<attrs.length; i++) {
String attrName = attrs[i].getName();
String attrValue = attrs[i].toString();
process(pjae, attrName, attrValue);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -