- How do I rename print-to-file filename at runtime?

D

Dan

I am trying to convert a bunch of different format files (.jpg/.pdf/.doc) to
..pcl (print-to-file) in a batch procedure. I've used shellexecute to open
the files (with an associated application) and then send them to a printer
that is set up to print to a particular file name (myprint.pcl)

The problem with this is that myprint.pcl is overwritten every time a new
file is being sent for printing. How can I get this resolved i.e. how can I
rename the default file name (myprint.pcl to say my_batch_file_name.pcl) at
runtime?

Ideally, I would be looking for an API that would allow me to control this
parameter (read-write) at runtime and, of course, a sample would be highly
desirable.
 
T

Terry

Dan said:
I am trying to convert a bunch of different format files (.jpg/.pdf/.doc) to
.pcl (print-to-file) in a batch procedure.

One way is to make the .BAT wait for the printing to be done, then do the
rename in the .BAT.

If that works, then look for this script on your system: PRNCFG.VBS

If you have that script, then you can use it in the .BAT like so:

... start the print job, %1 is the file to be printed ...
:try_again
cmd /c cscript prncnfg.vbs -p "name of your printer" -g | findstr
"printer status" | findstr "idle" > x
copy x y
if exist y goto printer_is_idle
sleep 30
goto try_again
:printer_is_idle
ren MYPRINT.PCL %1.PCL

OOPS!! You will need the "sleep" program:

#include <stdlib.h>
#include <windows.h>
int main(int argc, char** argv)
{
int sec_sleep = 1;
if (argc == 2)
sec_sleep= atoi(argv[1]);
Sleep(sec_sleep* 1000);
return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top