![]() |
|
|||||||
| Reporting / Printing Discussion on output-creation components such as reporting, pdf, etc. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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 |
|
||||
|
Quote:
)
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
|
|||
|
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 |
|
||||
|
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.
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
|
|||
|
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. |
|
||||
|
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.
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
|
||||
|
Follow the link in post 2.
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|