[Gambas-user] gambas3, question about printer and sending files to the printer
Richard Terry
rterry at ...1823...
Mon Sep 10 00:48:53 CEST 2012
Karl Reinl wrote:
> Salut Benoît,
>
> I look for a way to send a pdf or ps document to a printer, without
> passing by a pdf/ps viewer.
> Like I would do it with lpr/gtklp.
> But I would like to use the printer.Configure() dialogue.
> Do you see a possibility for that.
>
I use this in my medical records program to send the pdf directly to the
printer - just ignore the bits you don't need. Regarding the printer
dialog, not sure - I installed a samsung laser on my machine last week
and all of a sudden much to my annoyance my program started to present a
popup printer dialog. When I investigated it the linux common printing
stuff I'd installed had symlinked their lpr (which presumably contained
the dialog code) to the original lpr. When I changed it back the dialog
disappeared.
Regards
richard
Public Sub Print_PDF(pdf_path As String, Optional printertype As Integer
= const.Paper_Plain, number_copies As Integer = 1)
Dim cmd As String
If pdf_path = "" Then Return
Inc Application.Busy
cmd = modUtil.FindProgram("lpr", "cups")
If IsNull(cmd) Then Return
pdf_path = Replace$(pdf_path, " ", "\\ ")
pdf_path = "'" & pdf_path & "'" 'fixes baulking on odd instring
characters eg ( or )
cmd &= " " & GetOption(printertype)!lpr & " -# " & number_copies & "
" & pdf_path
Shell cmd Wait
Dec Application.Busy
End
Private Function GetOption(printertype As Integer) As Collection
Dim config_printer As String
Dim printername As String
Dim coll As New Collection
Dim printer_options As String
Dim i As String
config_printer = "Default"
Try config_printer = FMain.GetSelectedPrinter()
If config_printer = "" Then config_printer = "Default"
If config_printer <> "Default" Then
FMain.ResetPrinters()
Return Subst$("-P &1", config_printer)
Endif
Select Case printertype
Case const.Paper_Script
printername = "script"
Case const.Paper_Plain
printername = "plain"
Case const.Paper_Request
printername = "request"
Case const.Paper_Long
printername = "long"
End Select
config_printer = Settings[Subst$("Printers/&1", printername), "Default"]
printer_options = Settings[Subst$("Printers/&1_options",
printername), "Default"]
If printer_options <> "Default" Then
coll = SplitOptions(printer_options)
Endif
If config_printer <> "Default" Then
coll!lpr &= Subst$(" -P &1", config_printer)
Endif
Return coll
End
More information about the User
mailing list