Send a .pdf file to a specific printer

Hi,

I am writing an application in vb.net and need to send a pdf file to a specific printer.

I have been trying the following but it sends the pdf to my default printer?

    Public Function printFile(strFile As String, strPrinterName As String)


        Dim psi As New ProcessStartInfo

        Try
            psi.UseShellExecute = True
            psi.Verb = "print"
            psi.WindowStyle = ProcessWindowStyle.Hidden
            psi.Arguments = strPrinterName
            psi.FileName = strFile
            Process.Start(psi)

            Return "OK"
        Catch ex As Exception
            Return ex.Message
        Finally
            psi = Nothing
        End Try
    End Function

Regards,

Ross
ross13Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
I had to do it a while ago. I ended up setting the required printer as the default one (and reverting it after the print). Check http://emoreau.com/Entries/Articles/2005/03/Setting-Windows-default-printer.aspx
0
ross13Author Commented:
I spent a lot of time on this and found some software called PDFxchange. This is a free bit of software that you can call from the command line and you can pass the name of the printer that you are sending the print to.

Best regards,

Ross
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ross13Author Commented:
I can run multiple applications on the same PC without having to swap the default printer. Running multiple applications this was could possibly create a problem.  The solution I used for my project is to use third party software.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.