|
Hi there,
really helpfull stuff. I was just wondering if you knew if there were any codes for the JOB status([INT16] Status - the job status flags) . from what ive seen i usally get the follwoing values
1.) 0x0040
2.) 0x0000
3.) 0x4081
Any idea what any of those mean?
Thanks
|
|
|
|
|
Yes indeed :-
#Region "PrintJobStatuses"
<FlagsAttribute()> _
Public Enum PrintJobStatuses
JOB_STATUS_PAUSED = &H1
JOB_STATUS_ERROR = &H2
JOB_STATUS_DELETING = &H4
JOB_STATUS_SPOOLING = &H8
JOB_STATUS_PRINTING = &H10
JOB_STATUS_OFFLINE = &H20
JOB_STATUS_PAPEROUT = &H40
JOB_STATUS_PRINTED = &H80
JOB_STATUS_DELETED = &H100
JOB_STATUS_BLOCKED_DEVICEQUEUE = &H200
JOB_STATUS_USER_INTERVENTION = &H400
JOB_STATUS_RESTART = &H800
End Enum
#End Region
These values are flags - i.e. can be combined together in the status.
|
|
|
|
|
So, if i get a status 0x4081 that would mean
1.)' JOB_STATUS_PAPEROUT The print job is stalled because the printer has run out of paper
2.)JOB_STATUS_SPOOLING The print job is being added to the spooler queue
and 3.) JOB_STATUS_PAUSED The print job has been paused during printing
Can't see 0x0000 there though,
Alos i though your readers would find it usefull to know that on WIN 8 the signature is "0x00005123"
Cheers
|
|
|
|
|
0x0000 means everything is fine (status = READY)
I haven't run the spool file viewer on Win 8 - must do so over the weekend to make sure it works...thanks for the info.
P.S. All the printer / spooler API constants can be found in the code attached to the article Monitoring a Printer Queue from VB.NET[^]
modified 5-Jun-14 5:26am.
|
|
|
|
|
Hi thanks,
went through the code. But couldn't find 0x4081 anywhere?
|
|
|
|
|
It would be 0x4000 (which I don't know...maybe JOB_STATUS_RETAINED?) + 0x80 (JOB_STATUS_PRINTED) + 0x1 (JOB_STATUS_PAUSED)
|
|
|
|
|
Should I be able to view this file's contents by making use of a Struct?
If so, I'd like to use a FileSystemWatcher to fire events informing me of each print job's status based on the contents/existence of the SHD file.
Is there a better way of doing what I'm proposing? Currently I'm running a continuous WMI query, but it's too expensive i.t.o system resources.
|
|
|
|
|
|
SHD files created on 64 bit platforms will have offsets that are INT64 not INT32. (i.e. XP-64, Win2003-64, etc.)
An easy method for determining which platform your file was created on is checking the header size. 64 bit = 184 bytes, 32 bit = 120 bytes
- theGyre
|
|
|
|
|
Thanks - very good info, I'll try and get a 64bit machine to do some testing on...
|
|
|
|
|
I don't understand why you would access this file directly rather than using the GetJob API. Surely if you read the file yourself you are stuck with never ending problems every time MS release a new service pack/version and change the file format.
Tony Edgecombe
www.printdistributor.com
Easy output management
|
|
|
|
|
Yes - for jobs still in the print queue GetJob is definitely the prefered method.
This file format is primarily useful for archived job information (where print jobs are copied from the spool queue to a backup store)
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
Hi, I want to get the corrent page count of MS-Word document. Through the Internet,I find your artices about this. Can you send me some working codes & documents. I also find your source code in codeproject.com, but it does't work to my spooled .spl file.(My printer is Hp Laser Jet 1012) when i open .spl file, some GDI error occured. and i don't know how to debug it, because they're all wrappered into dlls. could you send me a copy of dll source code ?
My E-mail addr: muliu92@sohu.com
|
|
|
|
|
Parsing .spl files is more difficult as there are a larger number of possible formats. Files cam be EMF based or RAW printer language. The printer language in that case could be PostScript, PCL-5. PCL-XL (also known as PCL-6) , HP-GL etc.
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
Hi All
How to preview a Job in the Queue or Get the Contents of a Job in the Queue?
And
I want to decide the Size of The Document which user is printing, not the size of the Printing Job
How to Achive this?
welcome to discuess!
thanks
|
|
|
|
|
The first question is tricky but doable - I don't understand what you mean in the second question.
To preview all the print jobs in a queue you'd need to ensure that they had fully spooled then read each spool shadow file and determine what language the spool file itself is in then use a viewer appropriate to that language to view the file. There is an "EMF" viewer available in my articles on this site but you would also need to have one for PostScript, PCL-5, PCL-XL and any other printer control languages as might exist in your set-up.
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
Thanks for your help!
Can you give me a weblink to the "EMF" viewer? I can't find it!
and
I want to get the bytes of the document which the job contains! how to achive it ?
|
|
|
|
|
|
Hello all
Say I have a program - for which I have no source code, and it prints a "report" in this case it is actually a Point-Of-Sale RECEIPT going to either a SERIAL or PARALLEL printer port
I want tyo TRAP, the print Job, before it gets to the port, re-package it (add some Logo, and header / footer lines) and then let go of it to the intended printer..
Can this be done? Any suggestions please (using MFC / C++)
Thanks
Alex
|
|
|
|
|
The first step is to establish if the program is printing using the standard windows API (OpenPrinter, BeginPage, WritePrinter etc.) which goes via the spooler or whether it is writing directly to th eport itself.
If the former you should be able to select the printer (in control panel->printers) and set the option "Keep printed documents" on. This will write the spool file for the print job and by examining this it will be possible to find out what print language the program is spooling in.
This can be either EMF (in which case I have another article on decoding that on this site) or RAW {post script, PCL5, etc.} Then you need to create a service monitor the printer, pause newly arrived jobs and update the spool file with your bits and unpause it.
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
Hi Duncan
Well, that "Foreign" program is done by someone else - not me, so I have no idea if it prints directly to the prort or throgh the spooler, or what API's it is using to print.
What if it is writing to th eport directly? Can I intercept that in any way? How can I find out?
If I can see the file, how will I now what format it is in (EMF etc...)
Hope you can help me clear the fog...
Cheers
Alex
|
|
|
|
|
If it is using standard windows API then the printer should appear in the printers section of the control panel and you should get the standard printer icon appearing in the tool bar when you print a job on it.
If this is the case then I suggest you open the printer properties in control panel and in the "Advanced" tab select the check box marked "Keep printed documents".
When this is checked the spool files are kept after the print so you can examine them. In windows NT and related systems there are two files for each spooled print job...a .SHD file as documented above and a .SPL file that holds the actual print commands.
If you have a .SHD file, decode it as per the structure above and look at the string held in the .DataType member. If it is something tike "NT EMF 1.09" etc then it is an EMF print job and if it is "RAW" then it is in another printer language {PostScript, PCL-XL, PCL5, etc.}
If it is not using the printer API then the process is somewhat different...so best to try the above first.
HTH,
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
I test it in win2000(professional, SP4),
I use "Microsoft word 2000" + "HP Color LaserJet 3500 printer"
I print a document(2 pages and 6 copies), the "Pagecount" item's value is 2?
why?
I print same job with "HP LaserJet 4100" the "Pagecount" item's value is 12, it is right,
where can I find the "copy" item in SHD file?
thanks!
seaiam
|
|
|
|
|
There is a known issue[^] with Microsoft Word not reporting the correct number of copies to the spooler.
This is because the code they used to handle things like collation and reverse ordering is inside the application rather than querying and using the printer capabilities.
The only way to get the true page count for a Microsoft Word document is to parse the spool data file (.SPL). This is made slightly more difficult by the fact that the spool data file may contain one of a number of different formats: either EMF[^] or one of the RAW printer languages (PCL-5, PCL-XL, PostScript, HP-GL etc.)
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|