Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Printing to network printer via VB 2005

Status
Not open for further replies.

DotNetBlocks

Programmer
Apr 29, 2004
161
US
Hello,

Does anyone have an example of specifying the paper source and color settings when trying to print files in vb 2005?

Here is my current print function, but I need to be able to select the paper source and color settings.

Any help is much appreciated.

Babloome
Code:
Dim pathToExecutable As String = "C:\Program Files\Adobe\Acrobat 4.0\Reader\acrord32.exe"

''calling function
RunExecutable(pathToExecutable, "/t ""c:\testprint.pdf"" ""KONICA MINOLTA C252/C252P PCL""", 1)
            


    Public Sub RunExecutable(ByVal executable As String, ByVal arguments As String, ByVal AffilateID As Integer)
        Dim starter As New ProcessStartInfo(executable, arguments)
        starter.CreateNoWindow = True
        starter.RedirectStandardOutput = True
        starter.UseShellExecute = False
        Dim process As New Process()
        process.StartInfo = starter
        process.Start()
        Dim buffer As New StringBuilder()
        Using reader As StreamReader = process.StandardOutput
            Dim line As String = reader.ReadLine()
            While line IsNot Nothing
                buffer.Append(line)
                buffer.Append(Environment.NewLine)
                line = reader.ReadLine()
                Console.WriteLine(line)
                Thread.Sleep(100)
                process.CloseMainWindow()
                process.Close()
            End While
        End Using
        If process.ExitCode <> 0 Then

            Throw New Exception(String.Format("""{0}"" exited with ExitCode {1}. Output: {2}", executable, process.ExitCode, buffer.ToString()))

            My.Application.Log.WriteEntry(String.Format("""{0}"" exited with ExitCode {1}. Output: {2}", executable, process.ExitCode, buffer.ToString()) & " " & Now().ToString)

        End If
    End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top