How can I insert a pagefeed or newpage in this

Post Reply
User avatar
grayghost4
Posts: 54
Joined: Wednesday 05th December 2018 5:00am
Location: Concord, CA usa

How can I insert a pagefeed or newpage in this

Post by grayghost4 » Monday 30th December 2019 7:17am

I need a Page feed or new page at the comment below ... at line 37
' Gambas class file

Static Public iCkNumber As Integer
 Static Public ibankroute As String
 Static Public iaccountNumber As String 
 Static Public iStartCkNum As Integer = 25000
 

Public Sub Form_Open()

End

Public Sub Prn1_Draw()
Dim ix, inumpages As Integer
Dim mircnumber As String
Dim iCkNumber As Integer
iCkNumber = iStartCkNum

For inumpages = 1 To 3 
  iStartCkNum += 3

For ix = 0 To 400 Step 200

  Paint.Font = Font["Aeral, 12, bold "]
  Paint.DrawRichText(iCkNumber, 480, 25 + ix)
  Paint.Font = Font["Aeral,9"]
  Paint.DrawrichText("<b>John Doe JR.</b><br> 1234 Main Sr. <br>Hometown  Il 66152", 210, 35 + ix)
  Paint.DrawrichText("<u>Date______________________ </u>", 390, 65 + ix)
  Paint.DrawrichText("<small>Pay to the<br><u>order of:</u></small><u>_______________________________________________________________|</u>", 190, 80 + ix)
  Paint.DrawrichText("<h3>$<u>________________</u></h3> ", 472, 88 + ix)
  Paint.DrawrichText("<u>______________________________________________________________________________<small>Dollars</small></u>", 190, 120 + ix)
  Paint.Font = Font["MICR Encoding,18"]
  mircnumber = Str("a7200012345a c8543987c") & Str(iCkNumber)
  Paint.DrawRichText(mircnumber, 197, 200 + ix)
  Inc iCkNumber
Next 'ix
                                 ' need page feed here
Next
End

Public Sub Button1_Click()

 If Prn1.Configure() Then Return
 Prn1.Print()

End

User avatar
jornmo
Site Admin
Posts: 219
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: How can I insert a pagefeed or newpage in this

Post by jornmo » Monday 30th December 2019 8:58am

Try by using gb.pdf

User avatar
grayghost4
Posts: 54
Joined: Wednesday 05th December 2018 5:00am
Location: Concord, CA usa

Re: How can I insert a pagefeed or newpage in this

Post by grayghost4 » Monday 30th December 2019 2:51pm

jornmo wrote:
Monday 30th December 2019 8:58am
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

User avatar
jornmo
Site Admin
Posts: 219
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: How can I insert a pagefeed or newpage in this

Post by jornmo » Monday 30th December 2019 3:19pm

Sorry! I am on the beach in Gran Canaria :)
Take a look at the farm. Should be an example there.

User avatar
grayghost4
Posts: 54
Joined: Wednesday 05th December 2018 5:00am
Location: Concord, CA usa

Re: How can I insert a pagefeed or newpage in this

Post by grayghost4 » Wednesday 01st January 2020 7:53am

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.

User avatar
stevedee
Posts: 196
Joined: Monday 20th March 2017 6:06pm

Re: How can I insert a pagefeed or newpage in this

Post by stevedee » Wednesday 01st January 2020 4:32pm

grayghost4 wrote:
Wednesday 01st January 2020 7:53am
...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):-
Public SimpleText_p1 As String
Public SimpleText_p2 As String

Public Sub Form_Open()
  pr1.Count = 2      'number of pages to print
  SimpleText_p1 = "HELLO!" & Chr(10) & "Intro: This book describes all I know about printing."
  SimpleText_p2 = "That's it!" & Chr(10) & "goodbye!"
End

Public Sub pr1_Draw()
Dim strText As String


  Paint.Font = Font["Liberation Serif,12"]
  Paint.Color(Color.Black)

  Select Case pr1.Page     'which page are we printing this time?
    Case 1
      strText = SimpleText_p1
    Case 2
      strText = SimpleText_p2
    Case Else
      strText = "...what just happened?"
  End Select
  Paint.DrawText("Page number: " & pr1.Page & Chr(10) & strText, 50, 50)
  Paint.Fill
  
Catch
  lblErrors.Text = Error.Text
End

Public Sub bPrintPlain_Click()
  If pr1.Configure() Then Return 'if user clicks Cancel, don't continue
  pr1.Print

Catch
  lblErrors.Text = Error.Text
End
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.
Last edited by stevedee on Wednesday 01st January 2020 5:10pm, edited 3 times in total.

User avatar
cogier
Site Admin
Posts: 404
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: How can I insert a pagefeed or newpage in this

Post by cogier » Wednesday 01st January 2020 5:26pm

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.

User avatar
stevedee
Posts: 196
Joined: Monday 20th March 2017 6:06pm

Re: How can I insert a pagefeed or newpage in this

Post by stevedee » Wednesday 01st January 2020 5:34pm

cogier wrote:
Wednesday 01st January 2020 5:26pm
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: http://gambaswiki.org/wiki/comp/gb.qt4/printer/.begin

User avatar
grayghost4
Posts: 54
Joined: Wednesday 05th December 2018 5:00am
Location: Concord, CA usa

Re: How can I insert a pagefeed or newpage in this

Post by grayghost4 » Thursday 02nd January 2020 4:44am

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

Post Reply