hi guys,
actually I want to know how to access print job in the print spooler or print server. Thing is I want to do as follows:
I want to develop a tool for counting print jobs of the printers in the print servers and get how many number of pages are printed and also get owner machine of print job in the network.
I got
JOB_INFO_2 structure in the msdn but I want to do in java. I wrote simple program using java. but it will give only printer name and small things. I want to get what is the machine print job coming from and how many pages in that print job. I have included msdn struct and simple java class that I have written. as per the msdn doc, all the print jobs are associated with all those parameters, but how we access and retrieve them using java. hope you guys help me in this case..
--------------------------------MSDN Struct--------------------------------------------------------------
typedef struct _JOB_INFO_2 {
DWORD JobId;
LPTSTR pPrinterName;
LPTSTR pMachineName;
LPTSTR pUserName;
LPTSTR pDocument;
LPTSTR pNotifyName;
LPTSTR pDatatype;
LPTSTR pPrintProcessor;
LPTSTR pParameters;
LPTSTR pDriverName;
LPDEVMODE pDevMode;
LPTSTR pStatus;
PSECURITY_DESCRIPTOR pSecurityDescriptor;
DWORD Status;
DWORD Priority;
DWORD Position;
DWORD StartTime;
DWORD UntilTime;
DWORD TotalPages;
DWORD Size;
SYSTEMTIME Submitted;
DWORD Time;
DWORD PagesPrinted;
} JOB_INFO_2, *PJOB_INFO_2;
----------------------------END of MSDN Struct-----------------------------------------------------------
package it.dmm.printer;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.Attribute;
import javax.print.attribute.AttributeSet;
public class Printer {
public static void main(String[] args) {
PrintService printer = PrintServiceLookup.lookupDefaultPrintService();
AttributeSet att = printer.getAttributes();
for (Attribute a : att.toArray()) {
String attributeName;
String attributeValue;
attributeName = a.getName();
attributeValue = att.get(a.getClass()).toString();
System.out.println(attributeName + " : " + attributeValue);
}
}
}
results are :
queued-job-count : 0
color-supported : supported
printer-is-accepting-jobs : accepting-jobs
printer-name : Microsoft XPS Document Writer
please help asap for this case..