Monday, August 10, 2009

Perl Printing in Windows

In order to print a document from a perl based program the easiest option I have found is to save the document by printing to a File Handle, then run a system command to print the document.

This method is great for dynamically creating a formatted HTML document, saving it to a file by printing to the File Handle, then calling the system comman
d below to print the html document.

system('rundll32.exe %SystemRoot%\system32\mshtml.dll,PrintHTML "file://c:\perl\myfile.html"');
This command will open the printer dialog so the user can select a printer and other options.



Thanks to Rob's site for showing me how to use the rundll32 command.

Using the system command creates a problem when trying to run a console free application, however I will address this in another post.


No comments:

Post a Comment