[Gambas-user] New Printer example
Fabien Bodard
gambas.fr at ...626...
Sun Sep 30 21:18:39 CEST 2012
Public Sub GetPrinterResolution()
Dim sResultPath, sResultRow As String
Dim iPosition As Integer
Shell "locate -b *.ppd | grep " & myPrinter.Name To sResultPath
Shell "grep '*DefaultResolution:' " & sResultPath To sResultRow
iPosition = InStr(sResultRow, Chr(58))
iPrinterDPI = Mid(sResultRow, iPosition + 2, -4) ' FS-1030D = 600 dpi
End
Well...
Printer.Resolution ?
http://gambasdoc.org/help/comp/gb.qt4/printer/resolution?v3
This example can use Paint.width and paint.height to get the size of the support
Nevertheless:
I can do :
Public Sub Main()
Dim hReportImage As New ReportImage(Report)
Dialog.Path = User.Home
If Not Dialog.OpenFile() Then
Try hReportImage.Image = Image.Load(Dialog.Path)
If Error Then
Message.Error("Cannot Load Image: " & Dialog.Path)
Return
Endif
Else
Return
Endif
'The picture have it's good proportions
hReportImage.Stretch = Report.Proportional
'The Picture take all the space on the page
hReportImage.Expand = True
'a margin arround the page
Report.Padding = ReportPadding["1 cm"]
'Preview ? ... and printing
Report.Preview()
End
It's less line of code for the same thing
If someone want to help me to document gambas reports...
And you can add this too :
if hReportImage.Image.Height < hreportImage.Image.Width then
Report.Orientation = printer.Landscape
More information about the User
mailing list