How can I insert a pagefeed or newpage in this

Post

Posted
Rating:
#1 (In Topic #356)
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
I need a Page feed or new page at the comment below … at line 37

Code (gambas)

  1. ' Gambas class file
  2.  
  3.  Static Public ibankroute As String
  4.  Static Public iaccountNumber As String
  5.  Static Public iStartCkNum As Integer = 25000
  6.  
  7.  
  8. Public Sub Form_Open()
  9.  
  10.  
  11. Public Sub Prn1_Draw()
  12. Dim ix, inumpages As Integer
  13. Dim mircnumber As String
  14. Dim iCkNumber As Integer
  15. iCkNumber = iStartCkNum
  16.  
  17. For inumpages = 1 To 3
  18.   iStartCkNum += 3
  19.  
  20. For ix = 0 To 400 Step 200
  21.  
  22.   Paint.Font = Font["Aeral, 12, bold "]
  23.   Paint.DrawRichText(iCkNumber, 480, 25 + ix)
  24.   Paint.Font = Font["Aeral,9"]
  25.   Paint.DrawrichText("<b>John Doe JR.</b><br> 1234 Main Sr. <br>Hometown  Il 66152", 210, 35 + ix)
  26.   Paint.DrawrichText("<u>Date______________________ </u>", 390, 65 + ix)
  27.   Paint.DrawrichText("<small>Pay to the<br><u>order of:</u></small><u>_______________________________________________________________|</u>", 190, 80 + ix)
  28.   Paint.DrawrichText("<h3>$<u>________________</u></h3> ", 472, 88 + ix)
  29.   Paint.DrawrichText("<u>______________________________________________________________________________<small>Dollars</small></u>", 190, 120 + ix)
  30.   Paint.Font = Font["MICR Encoding,18"]
  31.   mircnumber = Str("a7200012345a c8543987c") & Str(iCkNumber)
  32.   Paint.DrawRichText(mircnumber, 197, 200 + ix)
  33.   Inc iCkNumber
  34. Next 'ix
  35.                                  ' need page feed here
  36.  
  37. Public Sub Button1_Click()
  38.  
  39.  If Prn1.Configure() Then Return
  40.  Prn1.Print()
  41.  
  42.  
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
jornmo is in the usergroup ‘Regular’
Try by using gb.pdf

Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’

jornmo said

Try by using gb.pdf

I am not smart enough to know how to implement that  :(

could you give an example ?

I have tried :   
Paint.DrawRichText(Chr$(12))  
did not work  :x

also tried :
Paint.DrawRichText(gb.pdf)   
gave an error of unknown …. pdf
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
jornmo is in the usergroup ‘Regular’
Sorry! I am on the beach in Gran Canaria  :)
Take a look at the farm. Should be an example there.

Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
I still have not found a "new page"  command … but have rewritten the routine to accomplish the same results  :D

It would be nice to learn how to implement a page brake.

In the meantime I have a lot to learn about Gambas.
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Regular
stevedee is in the usergroup ‘Regular’

grayghost4 said

…It would be nice to learn how to implement a page brake…

I don't think you need a page-break for a modern printer.

The key to this is that the printer prints on a new page every time you tell it to print (i.e. via the Printer_Draw event). So to print several pages, use Printer.Count & Printer.Page to control your program so that the Printer_Draw() event fires for each page that you require.

Unfortunately I'm having all sorts of Gambas printer problems, but these are not really related to your question. However, take a look at this test code (which uses Paint.DrawText because of my problems):-

Code (gambas)

  1. Public SimpleText_p1 As String
  2. Public SimpleText_p2 As String
  3.  
  4. Public Sub Form_Open()
  5.   pr1.Count = 2      'number of pages to print
  6.   SimpleText_p1 = "HELLO!" & Chr(10) & "Intro: This book describes all I know about printing."
  7.   SimpleText_p2 = "That's it!" & Chr(10) & "goodbye!"
  8.  
  9. Public Sub pr1_Draw()
  10. Dim strText As String
  11.  
  12.  
  13.   Paint.Font = Font["Liberation Serif,12"]
  14.   Paint.Color(Color.Black)
  15.  
  16.   Select Case pr1.Page     'which page are we printing this time?
  17.     Case 1
  18.       strText = SimpleText_p1
  19.     Case 2
  20.       strText = SimpleText_p2
  21.     Case Else
  22.       strText = "...what just happened?"
  23.   Paint.DrawText("Page number: " & pr1.Page & Chr(10) & strText, 50, 50)
  24.   Paint.Fill
  25.  
  26.   lblErrors.Text = Error.Text
  27.  
  28. Public Sub bPrintPlain_Click()
  29.   If pr1.Configure() Then Return 'if user clicks Cancel, don't continue
  30.   pr1.Print
  31.  
  32.   lblErrors.Text = Error.Text
  33.  

This works except it prints blank pages the 1st time I press the button, but then it prints both pages on subsequent presses OK. I hope this at least gives you the idea that you print pages based upon page count & number.
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Guru
cogier is in the usergroup ‘Guru’
Gerry Buzolic's book - Gambas from Zip

There is printing information here

You can download Gerry Buzolic's book here. You will also find a zip file with example programs. I notice it contains 2 programs on printing. I hope it helps.
Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Regular
stevedee is in the usergroup ‘Regular’

cogier said

Gerry Buzolic's book - Gambas from Zip

…I notice it contains 2 programs on printing. I hope it helps.

Its a great book, but it doesn't deal with pagination.

Key comments in the Gambas Documentation include: /comp/gb.qt4/printer/.begin - Gambas Documentation
Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
 stevedee:  
Thanks for the listing you put up… Got it working with :

Printer1.Count = inumofpages

That works kinda like a For Next loop      

and in my case I don't need  paint.fill
Online now: No Back to the top
1 guest and 0 members have just viewed this.