And that is in the preview so it looks perfect, but when printing nothing gets printed .
This is the code
Var rpt As New Report1
Var ps As New PrinterSetup
If ps.ShowPageSetupDialog Then
Var g As Graphics
g = ps.ShowPrinterDialog
Var rs As RowSet
rs = DB.SelectSQL("SELECT * FROM cheque")
If g <> Nil Then
If rpt.Run(rs,ps) Then
If rpt.Document <> Nil Then
rpt.Document.Print(g)
End If
End If
End If
End If
and this is the report , so what I am doing wrong ? as I don’t get it
ho boy , that PageSetup dialog is quite annoying , apparently for my other receipt project I need to do a weird step.
So I Select this , then I print in pdf then I print again, and select the proper printer and print and it works
No idea what to do,
Can this Page Setup be set once, saved as data and then called every time is needed ? so we can just show the printer and done ? or even the printer can we save it once and skip showing it and print it each time on same printer ?
yes, this is what I mentioned earlier, however, on the 3rd parameter in my case
g.DrawText(ammountInwords, 20, 90, 250) on 250 it will split into a new line but the text under should go more down than it is now, so the question is , can we set the space between lines to be bigger ?
Hi Tim, I’m not sure I get it as the g.DrawText does that automatically, based on the 4th parameter which is maxWidth based on the docs and the only parameter I have is the condense which is false.
So in my case using g.TextHeight how would that help ? as how I said earlier the method does the splitting and I cannot control it .
I guess it would be nice to have like in Word , I guess it is called LineSpacing and it will setup the space that you have between lines.
If you need to control the split of a line, you can do something like this:
Function SplitLinesToFit(g as Graphics, txt as String, width as double) as String()
Dim arr() as String = split(txt)
Dim lines() as string
While ubound(arr) > -1
Dim words() as string
// add words until we go over the desired width
Dim curWidth as double
While curWidth <= width and ubound(words) < ubound(arr)
Words.Add arr(ubound(words)+1)
CurWidth = g.stringWidth(join(words, " "))
Wend
// Remove the last word that made us go over
If ubound(words) < ubound(arr) then
Words.RemoveAt(ubound(words))
End if
// remove the words we used from arr
For I as integer = 0 to ubound(words)
Arr.removeAt(0)
Next I
// make a line for the ones we did
Lines.Add join(words, " ")
Wend
Return lines
End Function