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.