Printing to a Printer

Post

Posted
Rating:
#1 (In Topic #1409)
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
 Hi everyone,

I was wondering if someone could help me out a little bit as I'm a little lost (information overload ready I think)

I have a report I have made on screen using a textbox set to multiplied rows

What I would like to do now is send the report to the printer (or create the report as a print preview etc)

So could someone show me a basic way of sending something to a normal installed printer on Debian please.


Thanks for any guidance

Andy
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
this is a hard concept to get your head around … at least it was for me  :)

Take a look at this thread, read it all the way through … before trying it.

Gambas One - Gambas ONE

Also do a forum search for …. Printer1.print … will yield several threads about printing
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
Sending to a printer is totally different than on screen.  It is a steep learning curve but I use the printer object and then manually write the report. It uses x and y coordinates measured in millimeters so can plan the report and use a ruler to set the print version up. below is the part that does the printing.  the work is done in the pain.draw commands

Code

Public Sub rPmtReport_Draw()
  
  Dim SSlsID, D1, D2, PmtType, PmtDesc As String
  Dim pmtAmount, TTL As Float
  Dim Y, Colmn1, Colmn2, Colmn3, Colmn4, Colmn1W, Colmn2W, Colmn3W, Colmn4W, X, FRec, LRec As Integer
  
  D1 = Format(dStart.Value, "yyyy-mm-dd")
  D2 = Format(dEnd.Value, "yyyy-mm-dd")
  
  Colmn1W = 80
  Colmn2W = 100
  Colmn3W = 100
  Colmn4W = 100
  
  Colmn1 = 20
  Colmn2 = Colmn1 + Colmn1W
  Colmn3 = Colmn2 + Colmn2W
  Colmn4 = Colmn3 + Colmn3W
  TTL = 0
  
  Y = ReportHeader("Payment Report", D1, D2)
  
  Y = PmtReportTitles(Y)
  LRec = rPmtReport.Page * LinesPerPage
  If rPmtReport.Page = 1 Then
    FRec = 0
  Else
    FRec = (rPmtReport.Page - 1) * LinesPerPage + 1
  Endif
  If LRec > lstTemp2.Count Then LRec = lstTemp2.Count
  
  For X = FRec To Lrec
    SSlsID = FuncLib.GetFieldByPlace(lstTemp2[x].Text, FuncLib.cFieldDelimiter, 1)
    If SSlsID <> "" Then
      PmtType = FuncLib.GetFieldByPlace(lstTemp2[x].Text, FuncLib.cFieldDelimiter, 2)
      PmtDesc = FuncLib.GetFieldByPlace(lstTemp2[x].Text, FuncLib.cFieldDelimiter, 3)
      pmtAmount = FuncLib.Strip(FuncLib.GetFieldByPlace(lstTemp2[x].Text, FuncLib.cFieldDelimiter, 4))

      Paint.DrawText(SSlsID, Colmn1, Y, Colmn1W, 10, Align.Left)
      Paint.DrawText(PmtType, Colmn2, Y, Colmn2W, 10, Align.Left)
      Paint.DrawText(PmtDesc, Colmn3, Y, Colmn3W, 10, Align.Left)
      Paint.DrawText(Format(pmtAmount, "##,##0.00"), Colmn4, Y, Colmn4W, 10, Align.Right)
      Y += 15
    Endif
  Next
  
  Paint.FillRect(1, Y, Paint.Width, 2, Color.Black)
  Y += 12
  Paint.Font.Bold = True
  
  If rPmtReport.Count = rPmtReport.Page Then
    
    For X = 0 To lstTemp.Count
      PmtDesc = FuncLib.GetFieldByPlace(lstTemp[x].Text, FuncLib.cFieldDelimiter, 1)
      If PmtDesc <> "" Then
        PmtType = FuncLib.GetField(ByRef PmtDesc, ",")
        pmtAmount = FuncLib.Strip(FuncLib.GetFieldByPlace(lstTemp[x].Text, FuncLib.cFieldDelimiter, 2))
        TTL += pmtAmount
        Paint.DrawText(PmtType, Colmn1, Y, Colmn1W, 10, Align.Left)
        Paint.DrawText(PmtDesc, Colmn2, Y, Colmn2W, 10, Align.Left)
        Paint.DrawText(Format(pmtAmount, "##,###,##0.00"), Colmn3, Y, Colmn3W, 10, Align.Right)
        Y += 12
      Endif
    Next
    Y += 10
    Paint.DrawText("Total Pmts", Colmn2, Y, Colmn2W, 10, Align.Left)
    Paint.DrawText(Format(TTL, "##,###,##0.00"), Colmn3, Y, Colmn3W, 10, Align.Right)
    
  Endif
  Paint.DrawText("Page " & Str(rPmtReport.Page) & " of " & Str(rPmtReport.Count), 1, Paint.Height - 30, Paint.Width, 12, Align.Center)
  
  'Paint.End

  
End
Online now: No Back to the top
1 guest and 0 members have just viewed this.