Printing problems

blumonde

Well-known member
Joined
Jul 26, 2005
Messages
68
Programming Experience
Beginner
Gentlemen,

I use the sub below to print the application help manual. The problem is that it stops printing after the first page. How can I fix this so it will print the next page or until nothing more to print. The help manual is about a page and a half.

Please help.

blumonde




PrivateSub document_PrintPage(ByVal sender AsObject, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles docToPrint.PrintPage

' Insert code to render the page here.

Dim sHelptoprint AsString

sHelptoprint = Me.Text & vbCrLf & vbCrLf & vbCrLf & vbCrLf & Me.mtxHelp.Text

' The following code will render a simple

' message on the printed document.

Dim text AsString = sHelptoprint

Dim printFont AsNew System.Drawing.Font _

("Arial", 9, System.Drawing.FontStyle.Regular)

' Draw the content.

e.Graphics.DrawString(text, printFont, _

System.Drawing.Brushes.Black, 10, 10)

EndSub

 
Last edited:
all you need is to check if there is left text to be printed ... actually it is not such trivial job as it may looks on first sight. Not at all if you don't know how much pages there are. In that case you will need to make a function that counts all words and lines but however if you know the number of pages it should look as it follows:


'say you want to print 5 pages
VB.NET:
[/color][/size][size=2][color=#0000ff]Static[/color][/size][size=2] pageNo [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]Integer
 
[/color][/size][size=2][color=#0000ff][size=2][color=seagreen]'rest of the code come here ....[/color][/size]
 
[size=2]pageNo = pageNo + 1
 
[/size][size=2]
[/size]If[/color][/size][size=2] pageNo < 5 [/size][size=2][color=#0000ff]Then
[/color][/size][size=2]e.HasMorePages = [/size][size=2][color=#0000ff]True
 
[/color][/size][size=2][color=#0000ff]Else
 
[/color][/size][size=2]e.HasMorePages = [/size][size=2][color=#0000ff]False
 
[/color][/size][size=2][color=#0000ff]End [/color][/size][size=2][color=#0000ff]If

Regards ;)
 
kulrom said:
all you need is to check if there is left text to be printed ... actually it is not such trivial job as it may looks on first sight. Not at all if you don't know how much pages there are. In that case you will need to make a function that counts all words and lines but however if you know the number of pages it should look as it follows:


'say you want to print 5 pages
VB.NET:
[/color][/size][size=2][color=#0000ff]Static[/color][/size][size=2] pageNo [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]Integer
 
[/color][/size][size=2][color=#0000ff][size=2][color=seagreen]'rest of the code come here ....[/color][/size]
 
[size=2]pageNo = pageNo + 1
 
[/size][size=2]
[/size]If[/color][/size][size=2] pageNo < 5 [/size][size=2][color=#0000ff]Then
[/color][/size][size=2]e.HasMorePages = [/size][size=2][color=#0000ff]True
 
[/color][/size][size=2][color=#0000ff]Else
 
[/color][/size][size=2]e.HasMorePages = [/size][size=2][color=#0000ff]False
 
[/color][/size][size=2][color=#0000ff]End [/color][/size][size=2][color=#0000ff]If

Regards ;)

Hiya kulrom :)

When I add the statement e.hasmorepages = true, it prints out only the first page over and over until I cancel it.

What can I do?

blumonde
 
kulrom said:
Well, do you know the number of pages before you send it to print?
Also, let me know what is the format of the file you want to print or it is multiline textBox (i don't think so but however)?

Kulrom,

I got it now. I use the line count as you suggested and it works.

Thanks.

Cheers, :)

blumonde
 
Back
Top