in reply to Printing Image within Gtk-Perl Application

I asked a similar question (perhaps on another forum) several years ago. I received an answer which I do not understand (and was reluctant to try). It worked great for me. For what it is worth, here is the code which I found on an old backup disk. (It prints a PDF file where $pdf is the name of the file.)
my $shellopen = new Win32::API( "shell32", "ShellExecute", ['N', 'P', 'P', 'P', 'P', 'I'], 'N' ); $shellopen->Call(0, "print", $pdf, 0, 0, 0);

Clearly this only works on windows. I am nearly certain that I have used it on both XP and Windows 7.

Bill

Replies are listed 'Best First'.
Re^2: Printing Image within Gtk-Perl Application
by pryrt (Abbot) on Feb 06, 2019 at 16:37 UTC

    I am not a Win32::API expert, but I think I can help interpret that (in case someone else is reluctant to try, based on your historical reluctance to try):

    my $shellopen = new Win32::API( "shell32", "ShellExecute", ['N', 'P', 'P', 'P', 'P', 'I'], 'N' );
    This uses the IMPORTING A FUNCTION BY PROTOTYPE feature of Win32::API to set up a wrapper for the Windows API function ShellExecute() from the shell32.dll
    $shellopen->Call(0, "print", $pdf, 0, 0, 0); This calls the "print" verb defined in the Windows registry. This is the same as right-clicking on the file and selecting Print from the context menu in Windows Explorer.
      Thanks for the explanation and supporting references. I barely know that there is such a thing as "Windows API". At least now, I can tell that this code does exactly what I want and nothing else.
      Bill
Re^2: Printing Image within Gtk-Perl Application
by dabella12 (Acolyte) on Feb 07, 2019 at 02:50 UTC
    I'm working on a Linux system