Question Printing in Landscape

usamaalam

New member
Joined
Apr 12, 2011
Messages
1
Programming Experience
5-10
Hello Everybody,

I am using following method to print a file programmatically. Is there a way to tell the program to print the file in landscape?

VB.NET:
Public Function PrintPDF(ByVal PDFFile As String, ByVal Printer As String, ByVal Timeout As Integer) As Integer

        If PrinterName.Trim.Length = 0 Then
            PrinterName = (New System.Drawing.Printing.PrinterSettings).PrinterName
        End If
        'PrinterName = "a"
        Dim Proc As New System.Diagnostics.Process

        Proc.EnableRaisingEvents = True
        Proc.StartInfo.FileName = PDFFile
        Proc.StartInfo.Arguments = Chr(34) + PrinterName + Chr(34)
        Proc.StartInfo.Verb = "PrintTo"
        Proc.StartInfo.WindowStyle = ProcessWindowStyle.Minimized
        Proc.StartInfo.CreateNoWindow = True
        If Proc.Start() = False Then
            Exit Function
        End If

        'Do While Timeout > 0 AndAlso Not Proc.HasExited
        '    System.Threading.Thread.Sleep(1000)
        '    Timeout -= 1
        'Loop

        If Not Proc.HasExited Then
            Debug.Print("Killing process")
            Proc.Kill()
        End If

        Debug.WriteLine("Closing process")
        Proc.Close()

        Return 0
    End Function

Thanks.
 
Back
Top