File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes how to access print job in print spooler or print server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "how to access print job in print spooler or print server" Watch "how to access print job in print spooler or print server" New topic

how to access print job in print spooler or print server

Dilanka Muthukumarana

Joined: Mar 28, 2009
Posts: 11

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 {
LPTSTR pPrinterName;
LPTSTR pMachineName;
LPTSTR pUserName;
LPTSTR pDocument;
LPTSTR pNotifyName;
LPTSTR pDatatype;
LPTSTR pPrintProcessor;
LPTSTR pParameters;
LPTSTR pDriverName;
LPTSTR pStatus;
DWORD Status;
DWORD Priority;
DWORD Position;
DWORD StartTime;
DWORD UntilTime;
DWORD TotalPages;
DWORD PagesPrinted;

----------------------------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..
I agree. Here's the link:
subject: how to access print job in print spooler or print server
It's not a secret anymore!