Printing Landscape in .Net

Yacko

Newcomer
Joined
Dec 11, 2003
Messages
1
Location
Topeka, KS
have this print function that I use to print my text
file. When this prints it uses the original printer
settings to print the first page and then all subsequent
pages follow the way I have this layed out. What am I
missing that the first page will not print the layout that
I'm asking for?

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

        Dim PD As New Printing.PrintDocument()
        Dim PageDoc As Printing.PageSettings = New 
Printing.PageSettings()
        Dim ppdlg As PrintPreviewDialog = New 
PrintPreviewDialog()
        Dim psdlg As PageSetupDialog = New PageSetupDialog
()
        Dim i As Integer
        Dim j As Integer
        Dim s As String
        Dim hline As Long
        Dim linesperpage As Single = 0
        Dim mfnt As Font = New Font("Courier New", 10, 
FontStyle.Bold, GraphicsUnit.Point)
        Dim mfnt2 As Font = New Font("Courier New", 10, 
FontStyle.Regular, GraphicsUnit.Point)

        Dim LineHeight As Single = mfnt.GetHeight
(e.Graphics)
        Dim LineHeight2 As Single = mfnt2.GetHeight
(e.Graphics)

        '*****************


        psdlg.Document = PD
        PD.DefaultPageSettings.Landscape = False
        e.PageSettings.Landscape = False
        e.HasMorePages = False
        psdlg.PageSettings.Landscape = False
        psdlg.Reset()
        PageDoc.Landscape = False


        'PrintDocument1.PrinterSettings.LandscapeAngle = 0
        '**********************



        j = 0
        For i = 0 To vList1.Items.Count - 1
            s = VB6.GetItemString(vList1, i)
            If VB.Left(VB6.GetItemString(vList1, i), 2) 
= "*B" Then
                j = 1
            Else
                If VB.Left(VB6.GetItemString(vList1, i), 
2) = "-B" Then
                    j = 0
                End If
            End If

            If VB.Left(VB6.GetItemString(vList1, i), 2) 
= "*B" Or VB.Left(VB6.GetItemString(vList1, i), 2) = "-B" 
Or VB.Left(VB6.GetItemString(vList1, i), 2) = "*P" Then
                If VB.Left(VB6.GetItemString(vList1, i), 
2) = "*P" Then
                    ' Need to put in advance to new page 
here '
                End If
            Else
                If j = 1 Then
                    hline += LineHeight
                    e.PageSettings.Landscape = False
                    e.Graphics.DrawString(s, mfnt, 
Brushes.Black, 1, hline)
                Else
                    hline += LineHeight2
                    e.PageSettings.Landscape = False
                    e.Graphics.DrawString(s, mfnt2, 
Brushes.Black, 1, hline)
                End If
            End If

        Next i
        Exit Sub
ErrHandler:
        Exit Sub
    End Sub
 
Back
Top