I have a question. I am a novice programmer needing help at work. I need to automate printing of several pdf files. A single pdf is created that needs to go to one or more clients in my company. I am in charge of automating this task. I have written a program in perlscript that does everything except the acual printing of the pdf. I need a way to simply print these pdf's out without user interaction. A command line program that accepts the file name would be useful. Any help on where to start?
what compiler are you using?
If you are using fstreams (fstream.h), try using an ofstream with the file PRN....then you can print...
ofstream print ( "PRN" );
print << "Printing to the printer......";
you would have to write a program that can open/read .pdf files (which is way more complicated than you could probably do as a novice programmer), fstreams just will not cut it.
Another option is to find a .pdf program that already has a print utility. You would need one that you could spawn and make external input commands to. (like CTRL P)
Then you may be able to open the file with the program, CTRL P, ENTER, ALT F4.
That is still pretty complicated and not at all very efficient.
Look up batch processing of .pdf files. That may help you as well.
See if you can find a ,pdf handler that is open source. (This won't be an Adobe sort of thing....)
I would imagine the biggest problem would be conversion of the pdf format into a print format (ASCII, images) that would be recognized by the printer.
Well......there is the easiest way....you could simply use the system
(Assuming you are using windows)
Compile as "PrintPDF" or whatever...
int WINAPI WinMain(HINSTANCE hThisInstance,
nRes = (int)ShellExecute(HWND_DESKTOP,"print",
MessageBox(HWND_DESKTOP,"Could not print","ERROR",MB_OK);
Use as a commandline
You will not see anything going to screen........but it should spit the document out of the printer.....
That's about the simplest and most effective way I can think of.
That helps alot. I am using windows and thought I could do somthing like that, but have never tried printing before. I found an extensive JAVA library for handling pdf's but it didn't seem to easy to print. Mainly most of the open source stuff out there is centered on making pdf's.
Fordy, thanks for the code however I must be doing something wrong. I have a copy of MS Visual C/C++ that I am using to compile my c programs. It gives me this error
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/printPDF.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
printPDF.exe - 2 error(s), 0 warning(s)"
The program will compile but not link. I don't understand modt of the code, so I couldn't find the error. Maybe I don't have a proper headder file installed.