|
-
Oct 9th, 2005, 06:47 PM
#1
Thread Starter
New Member
[RESOLVED] Problem printing (page drops down and to right)
I have a problem with printing in vb.net when using the printdocument and printpreview controls. When I use printpreview.showdialog the page(s) show up fine but when I click on the print icon the resulted page has dropped down and to the right.
I read of a similar problem where someone suggested that the printpreview control was setting up margins but when I tried to just use printdocument.print it still drops down and to the right.
Here is the code I use:
Code:
Private Sub prdDocument_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles prdDocument.PrintPage
Dim HeadingFont As New Font(FontFamily.GenericSansSerif, 30, FontStyle.Bold, GraphicsUnit.Pixel)
Dim BoldFont As New Font(FontFamily.GenericSansSerif, 20, FontStyle.Bold, GraphicsUnit.Pixel)
Dim NormalFont As New Font(FontFamily.GenericSansSerif, 20, FontStyle.Regular, GraphicsUnit.Pixel)
Dim MyBrush As New SolidBrush(Color.Black)
Dim MyPen As New Pen(Color.Black)
Dim Centerformat As New StringFormat
Dim Items As New ArrayList
Dim MyDivision As CDivision
Dim MyTeam As CTeam
Dim MyPlayer As CPlayer
Dim MyMatch As CMatch
Dim X As Integer
Dim Y As Integer
Dim Count1 As Integer
Dim Count2 As Integer
Dim Count3 As Integer
Dim Count4 As Integer
Dim PrintString As String
Centerformat.Alignment = StringAlignment.Center
MyDivision = clsPrintObject
e.Graphics.DrawString("Draw - " & MyDivision.Name, HeadingFont, MyBrush, (e.PageBounds.Width / 2), 75, Centerformat)
X = 50
Y = 150
Count3 = Y
For Count1 = 1 To clsControl.GetNumberRounds(MyDivision.ID)
Items.Clear()
clsControl.GetResults(MyDivision.ID, Count1, Items)
e.Graphics.DrawString("Round " & Count1 & " - " & Format(Items.Item(0).MatchTime, "h:mm tt"), BoldFont, MyBrush, X, Y)
Y = Y + 35
Count2 = 0
For Each MyMatch In Items
If MyMatch.Team1 <> 0 Or MyMatch.Team2 <> 0 Then
If MyMatch.Team1 <> 0 Then
clsControl.GetTeam(MyMatch.Team1, MyTeam)
Else
MyTeam = New CTeam
MyTeam.Name = "Bye"
End If
PrintString = "Field " & MyMatch.Field & ":" & vbTab & MyTeam.Name
If MyMatch.Team2 <> 0 Then
clsControl.GetTeam(MyMatch.Team2, MyTeam)
Else
MyTeam = New CTeam
MyTeam.Name = "Bye"
End If
PrintString = PrintString & " vs " & MyTeam.Name
e.Graphics.DrawString(PrintString, NormalFont, MyBrush, X, Y)
Y = Y + 35
Count2 = Count2 + 1
End If
Next
If Count1 Mod 3 = 0 Then
X = 50
Y = Count3 + 160
Count3 = Y
Else
X = X + 380
Y = Y - (35 * Count2) - 35
End If
Next
If clsPrintCollection.IndexOf(MyDivision) <> clsPrintCollection.Count - 1 Then
clsPrintObject = clsPrintCollection.Item(clsPrintCollection.IndexOf(MyDivision) + 1)
While clsControl.GetNumberRounds(clsPrintObject.ID) = 0 And clsPrintCollection.IndexOf(clsPrintObject) <> clsPrintCollection.Count - 1
clsPrintObject = clsPrintCollection.Item(clsPrintCollection.IndexOf(clsPrintObject) + 1)
End While
If clsControl.GetNumberRounds(clsPrintObject.ID) > 0 Then
e.HasMorePages = True
End If
End If
End Sub
Any Ideas?
Last edited by nbollom; Oct 17th, 2005 at 05:38 AM.
Reason: Project Due
-
Oct 10th, 2005, 06:26 AM
#2
Re: Problem printing (page drops down and to right)
You have not taken account of the non-printable area of the printer
(i.e. some printers cannot print all the way to the edge of the page so their x,y is offset by a bit).
-
Oct 10th, 2005, 07:04 AM
#3
Thread Starter
New Member
Re: Problem printing (page drops down and to right)
I don't think that's the problem as I start quite a distance from the edge and the printouts I have go almost to the bottom and right edges but ill try it anyway
Can you tell me how to get the printable area of a page?
-
Oct 17th, 2005, 05:37 AM
#4
Thread Starter
New Member
Re: [Urgent]Problem printing (page drops down and to right)
Just if anyone is wondering I worked out the solution
There is a property called OriginAtMargins in the printdocument. I had to set that to false in the printpage method
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|