Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find the spool file for the job with a given ID even when spool file pooling is enabled?

I would like to copy the spool data for a given Windows print job to an arbitrary location on disk.

I have the job ID of the print job from the Print Spooler API. I know this job has finished spooling. I know the job won't be deleted before I have time to complete whatever I need to do.

If file pooling is disabled, I can do this by looking in the spool directory for the file with format "xxxxx.spl", where xxxxx is the 0-padded job ID.

How can I do this if file pooling is enabled?

I'd be delighted if there was a method that took a job ID and returned a stream of the spool data, but that seems unlikely at this point. Supposedly something similar might be possible using OpenPrinter with "PrinterName,Job xxxx" and ReadPrinter as documented here, but so far I haven't been able to get it to work, and even if I do it looks like it loads the data into memory, and I'm not sure how this will work with large spool files (>1 GB is not unusual).

My second preference would be a way to pass in the ID and get back the location of the file with the spool data on disk (regardless of file pooling setting).

My third preference would be a way to map a pooled file ("FPyyyyy.spl") to the job ID it's for.

Are any of these feasible, or does anybody have a better idea about how to solve this issue?

(Edited to add since it wasn't clear that we were aware of this option): Our fallback is to require that our customers disable spool file pooling by editing the registry for each printer, but we would much prefer avoid this.

like image 213
Lawrence Johnston Avatar asked Oct 12 '12 20:10

Lawrence Johnston


People also ask

How do I open a spool file?

Select the menu File->Open in viewing the EMF spool file. A dialog box will appear allowing you to browse the spool file (with file extension .

In which format does data send to spool for processing?

Standard printer output The printer driver for the outbound spool printer will process data in the NJE-wrapped EBCDIC format. The printer driver converts the data to the format that the printer requires, adding control codes.


1 Answers

I figured out why my calls to OpenPrinter were failing and I have successfully read the spool data using OpenPrinter and ReadPrinter, which solves our problem nicely.

I'll still award the bounty to anybody who comes up with a better solution, though.

like image 149
Lawrence Johnston Avatar answered Oct 04 '22 12:10

Lawrence Johnston