dabella12 has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks I have a Gtk application that has users names and a picture of the user. i would like to know how i can print the image out with the user info to the printer
  • Comment on Printing Image within Gtk-Perl Application

Replies are listed 'Best First'.
Re: Printing Image within Gtk-Perl Application
by BillKSmith (Monsignor) on Feb 06, 2019 at 14:35 UTC
    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

      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
      I'm working on a Linux system