develooper Front page | perl.wxperl.users | Postings from March 2013

Sending Documents to The Printer

Mark Dootson
March 30, 2013 06:04
Sending Documents to The Printer
Message ID:

I've been trawling Google for references to wxPdfDocument to check on 
general questions / development as I have not looked at it in a while. I 
found a post asking how to send a pdf file directly to the printer, 
rather than opening it.

If your operating system supports associating document types with 
commands for printing and opening, the following will work for any 
document file type.

my $mtm = Wx::MimeTypesManager->new();
if( my $filetype = $mtm->GetFileTypeFromExtension('pdf') ) {
     my $cmd = $filetype->GetPrintCommand($filepath);
     Wx::ExecuteCommand($cmd) if $cmd;

Hope it is useful.

Mark Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About