G
Guest
Hello,
I can't seem to get printing to landscape working. Here is some of the code
I've tried.
'---------------------------------------------------------------------------------
Dim myDocument As PrintDocument = PreparePrintDocument()
Dim myPaperSize As PaperSize
Dim iSizeCount As Integer
Dim dlgPrint As New PrintDialog
iSizeCount = 0
' Set to our selected printer
myDocument.PrinterSettings.PrinterName = PrinterList.Text
' This hides the print progress dialog
myDocument.PrintController = New
System.Drawing.Printing.StandardPrintController
' Print Landscape
myDocument.PrinterSettings.DefaultPageSettings.Landscape.Equals(True)
For Each myPaperSize In myDocument.PrinterSettings.PaperSizes
If myDocument.PrinterSettings.PaperSizes(iSizeCount).Kind =
PaperKind.Number10Envelope Then
myDocument.DefaultPageSettings.PaperSize =
myDocument.PrinterSettings.PaperSizes(iSizeCount)
Exit For
End If
iSizeCount = iSizeCount + 1
Next
' Ok let's try landscape one more time...
myDocument.DefaultPageSettings.Landscape.Equals(True)
MsgBox(myDocument.DefaultPageSettings.Landscape.ToString)
'dlgPrint.Document = myDocument
'MsgBox(dlgPrint.PrinterSettings.DefaultPageSettings.Landscape.ToString)
'dlgPrint.ShowDialog()
'MsgBox(dlgPrint.PrinterSettings.DefaultPageSettings.Landscape.ToString)
dlgPrintPreview.Document = myDocument
dlgPrintPreview.ShowDialog()
'Print immediately.
'myDocument.Print(
'---------------------------------------------------------------------------------
The only time I ever get landscape to be active is if I display the
PrintDialog and allow the user to select it. I can't get it to work in code
no matter how many places I set it.
I can't seem to get printing to landscape working. Here is some of the code
I've tried.
'---------------------------------------------------------------------------------
Dim myDocument As PrintDocument = PreparePrintDocument()
Dim myPaperSize As PaperSize
Dim iSizeCount As Integer
Dim dlgPrint As New PrintDialog
iSizeCount = 0
' Set to our selected printer
myDocument.PrinterSettings.PrinterName = PrinterList.Text
' This hides the print progress dialog
myDocument.PrintController = New
System.Drawing.Printing.StandardPrintController
' Print Landscape
myDocument.PrinterSettings.DefaultPageSettings.Landscape.Equals(True)
For Each myPaperSize In myDocument.PrinterSettings.PaperSizes
If myDocument.PrinterSettings.PaperSizes(iSizeCount).Kind =
PaperKind.Number10Envelope Then
myDocument.DefaultPageSettings.PaperSize =
myDocument.PrinterSettings.PaperSizes(iSizeCount)
Exit For
End If
iSizeCount = iSizeCount + 1
Next
' Ok let's try landscape one more time...
myDocument.DefaultPageSettings.Landscape.Equals(True)
MsgBox(myDocument.DefaultPageSettings.Landscape.ToString)
'dlgPrint.Document = myDocument
'MsgBox(dlgPrint.PrinterSettings.DefaultPageSettings.Landscape.ToString)
'dlgPrint.ShowDialog()
'MsgBox(dlgPrint.PrinterSettings.DefaultPageSettings.Landscape.ToString)
dlgPrintPreview.Document = myDocument
dlgPrintPreview.ShowDialog()
'Print immediately.
'myDocument.Print(
'---------------------------------------------------------------------------------
The only time I ever get landscape to be active is if I display the
PrintDialog and allow the user to select it. I can't get it to work in code
no matter how many places I set it.