stephanm has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I'm trying to run a service on Vista that prints any pdf file dropped into a directory. The program works when started by hand.
When installed as service the print does not happen. I can see that AcroRd32 gets started but then hangs.### print files dropped into this directory use strict; use File::Copy; while(1) { opendir(DIRH, "c:\\printpdf") or die "couldn't open: $!"; open(FH, ">log.txt") or die "Cannot open log file"; foreach (readdir DIRH) { ### only take pdf files next unless /pdf$/i; ### acroread needs full path my $file = "c:\\PrintPDF\\$_"; print FH "Found $file\n"; #system "c:\\apps\\AcroRd32.lnk /p \"$file\""; system "c:\\apps\\AcroRd32.lnk /N /T \"$file\""; ### not sure how long acroread keeps the file open sleep 10; move("$_", "Done") or die "move failed: $!"; } close(FH); closedir(DIRH); sleep 30; }
I assume that is because a GUI program cannot be run as service.
I also tried a printing alternativ found on this site:
Same problem - works when started manually - hangs when started as service.use Win32::API; my $shellopen = new Win32::API("shell32", "ShellExecute", ['N', 'P', 'P', 'P', 'P', 'I'], 'N'); $shellopen->Call(0, "print", $file, 0, 0, 0);
Does anyone known a way to print PDFs w/o having to start any type of GUI application?
Thanx.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Printing PDFs as a windows service
by BrowserUk (Patriarch) on Jun 23, 2010 at 14:32 UTC | |
Re: Printing PDFs as a windows service
by brap (Pilgrim) on Jun 23, 2010 at 14:55 UTC | |
Re: Printing PDFs as a windows service
by petecm99 (Pilgrim) on Jun 23, 2010 at 18:47 UTC | |
by stephanm (Sexton) on Jun 25, 2010 at 02:24 UTC |
Back to
Seekers of Perl Wisdom