Visual Basic .NET Forums  

Go Back   Visual Basic .NET Forums > Components & Controls > Reporting / Printing

Reporting / Printing Discussion on output-creation components such as reporting, pdf, etc.

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-08-2009, 11:48 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jan 2009
Age: 22
Posts: 18
Reputation: 9
Blesson is on a distinguished programming path ahead
Default printing the contents of a text box?

now i am printing the contents of a text box, my problem is i am able to print only one page . i want to know how to test whether it has execeed one page and trigger the print page event again for the next pages.


i know that we have to use the e.hasmorepages=true but i dont know what the if condition will be.

my code is shown below.

Code:
    Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

        Dim font As New Font("Verdana", 14)
        Dim PrintAreaHeight, PrintAreaWidth, marginLeft, marginTop As Int32
        With PrintDocument1.DefaultPageSettings

            'initializing local variables that contain the bounds of the printing area rectangle
            PrintAreaHeight = .PaperSize.Height - .Margins.Top - .Margins.Bottom
            PrintAreaWidth = .PaperSize.Width - .Margins.Left - .Margins.Right
            marginLeft = .Margins.Left
            marginTop = .Margins.Top

            ' if the user selects landscape mode, swap the printing area height and width
            If PrintDocument1.DefaultPageSettings.Landscape Then
                Dim intTemp As Int32
                intTemp = PrintAreaHeight
                PrintAreaHeight = PrintAreaWidth
                PrintAreaWidth = intTemp
                ' if the user selects landscape mode, swap the printing area height and width
            End If

           ' initializing the rectangle structure that defines the printing area
            Dim rectPrintingArea As New RectangleF(marginLeft, marginTop, PrintAreaWidth, PrintAreaHeight)
            ' calculating the total number of lines in the document based on the height of
            ' the printing area and the height of the font
            Dim intLineCount As Int32 = CInt(PrintAreaHeight / font.Height)
            'instantiating the StringFormat class, which encapsulates text layout information
            Dim fmt As New StringFormat(StringFormatFlags.LineLimit)

            ' print the text to the page
            e.Graphics.DrawString(Mid(TextBox1.Text, 1), font, Brushes.Black, rectPrintingArea, fmt)

            'HasMorePages tells the printing module whether another PrintPage event should be fired
            e.HasMorePages = False
        End With

    End Sub



i want to know wat will be the criteria in the if condition

if(..........) then
e.hasmorepages=true
end if


Thanks

Last edited by JohnH; 01-08-2009 at 6:07 PM. Reason: thread split, different topic
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-08-2009, 6:05 PM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 36
Posts: 9,163
Reputation: 1079
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

Quote:
now i am printing the contents of a text box
How to print a txt file (do study the TextPrint class too )
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-09-2009, 1:20 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jan 2009
Age: 22
Posts: 18
Reputation: 9
Blesson is on a distinguished programming path ahead
Default

hi,
I checked it out but that is not what i am looking for . i would like to know how the print more than one page . i mean how to check if the no of lines have execeed the page limit and call the print page event again.

thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-09-2009, 6:36 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 36
Posts: 9,163
Reputation: 1079
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

How can it not be what you look for? The code you posted is a rip-out from that class - same code, same variable names, only missing a few lines of it. That class prints more than one page. You should copy it in full, use it, and study the code to learn from it.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-11-2009, 11:51 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jan 2009
Age: 22
Posts: 18
Reputation: 9
Blesson is on a distinguished programming path ahead
Default

sorry John I have not seen the link to the code. Howeve after you said looked again and found it. but i cannot the below code.

Public Sub New(ByVal Text As String)
' Sets the file stream
MyBase.New()
strText = Text
End Sub

1. I have no idea what this code does
2. Why is it used


Thanks.
I mean i dont know the concept of using public sub new.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-12-2009, 6:40 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 36
Posts: 9,163
Reputation: 1079
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

I posted the sample how to use the class and the constructor, look again. I see now the article also has a usage sample below.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-12-2009, 6:53 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jan 2009
Age: 22
Posts: 18
Reputation: 9
Blesson is on a distinguished programming path ahead
Default

Where can i find the the sample to use the class and constructor?.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 01-12-2009, 6:57 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 36
Posts: 9,163
Reputation: 1079
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

Follow the link in post 2.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 9:14 PM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0


For advertising opportunities click here.