Hey,

I've tried to figure out a way to print like 500+ .pdf files using Perl here in Windows, but my testings are rather limited since my printer's ink is no more.
However, after some research, Ive found some methods. The sub printFile is called for every file. I've tested with around 10 files. And now I need monks expertise!


Method #1:
use Win32::Printer::Direct; sub printFile { my $filename = shift; my $val = Printfile("HP DeskJet 870Cxi", $filename); return ($val == 1); }
This seems to be working the best, since EVERY file is added to the printqueue. However, can someone confirm the data printed is ok? It doesnt say amount of pages in the printqueue as it does with other ways mentioned below. Something about a "raw" print... Dont wanna have rubish on paper...

Method #2:
use Win32::API; my $shellopen = new Win32::API("shell32", "ShellExecute", ['N', 'P', 'P', 'P', 'P', 'I'], 'N'); sub printFile { my $filename = shift; if ($shellopen) { $shellopen->Call(0, "print", $filename, 0, 0, 0); print "Printing $filename...\n"; } }
This one doesnt seem to print every file. And if I add a sleep inside the if, only one is added to the printqueue, and then nothing seems to be happening. Doesnt even seem exit the sub. Wierdo.

Method #3:
my $exec = '"K:\\Program\\Adobe\\Acrobat 7.0\\Acrobat\\Acrobat.exe" /t + "a_pdf_file.pdf" "HP DeskJet 870Cxi"'; system($exec); system($exec); system($exec);
Well, this one kinda works, but next is not taken until I close the application.

So, anyone here got some bright ideas to solve this? The best would be to just let the app print em all, but seems like I have to add some kind of interaction... like print 10, wait for confirmation.. loop.
The thing is, I generate .pdf files, and after one is created the idea is to print it, delete it, and take next. However, it seems quite tricky, since the printing can't coop, and I may delete the file before it even reaches the printers buffer...

Thanks,
Ace

In reply to Printing MANY .pdf files in Windows by Ace128

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.