Hi,
I’m having some trouble to print things…
I have some data in a SQLite database that i have to print in label
format.
I’m using Pdf::Writer to configure the data in the page but i’m having
trouble when i execute the code to send the pdf file to the printer.
After a lot of researsh i get to this windows-only way to do this:
#Begining of the code
require ‘Win32API’
fname = ‘temp.pdf’
shell = Win32API.new(“Shell32”, “ShellExecute”, [‘L’, ‘P’, ‘P’, ‘P’,
‘P’, ‘L’], ‘L’)
shell.Call(0, “print”, fname, 0,0, 1)
#End of the code
This code works. I get the pdf printed but it opens an Adobe Reader
blank windows that i don’t want.
Do someone knows how to work it out?
Or have some better solution for this problem (even better if it is
multi-plataform)?
Thank you!
require ‘Win32API’
fname = ‘temp.pdf’
shell = Win32API.new(“Shell32”, “ShellExecute”, [‘L’, ‘P’, ‘P’, ‘P’,
‘P’, ‘L’], ‘L’)
shell.Call(0, “print”, fname, 0,0, 1)
Instead of ShellExecute, try ShellExecuteEx
Dunno if the syntax will be right for it but I know
that ShellExecuteEx doesn’t make the same calls to Com
like ShellExecute does…
I havn’t researched this tho…
If you have time to research the API, I would suggest the following:
Michael L. wrote:
require ‘Win32API’
fname = ‘temp.pdf’
shell = Win32API.new(“Shell32”, “ShellExecute”, [‘L’, ‘P’, ‘P’, ‘P’,
‘P’, ‘L’], ‘L’)
shell.Call(0, “print”, fname, 0,0, 1)
Instead of ShellExecute, try ShellExecuteEx
Dunno if the syntax will be right for it but I know
that ShellExecuteEx doesn’t make the same calls to Com
like ShellExecute does…
I havn’t researched this tho…
If you have time to research the API, I would suggest the following:
ShellExecuteA function (shellapi.h) - Win32 apps | Microsoft Learn
Thank you Mac, that helped a little. Now the Adobe Reader screen opens
up and closes. That’s not ideal, but better than a freaking windows left
open in every printing.
I’ll look out the msdn documentation, but if anyone can give me other
tips i’ll be gratefull.
Shameless self-promotion: cups - cups.rubyforge.org
*NIX only, unfortunately, but you can get printing stuff in =~ 3 LOC.
m0wf