1

We currently spin up adobe reader to print out a pdf from our legacy silverlight product which works fine with the following code:

Dim shell = AutomationFactory.CreateObject("Shell.Application")
shell.ShellExecute(path, "", "", "print", 1)

This works great, the problem is that after the printing has been done the Adobe reader application is still left open which is a little annoying to the user base.

My question is how do we close the adobe reader application from code?

Thanks

Matt
  • 3,305
  • 11
  • 54
  • 98
  • [Here](http://stackoverflow.com/questions/5085491/closing-an-instance-of-acrobat-reader-from-command-line?lq=1) and [there](http://www.codeproject.com/Tips/598424/How-to-Silently-Print-PDFs-using-Adobe-Reader-and) they say it can only be killed. – user2846289 Nov 15 '13 at 08:40
  • By using /n /p it'll open a new reader and will close it if it's not the last one. You could count the number of instance opened, if there's no instance then kill it at the end. If there was already an instance then you don't need to kill it (/n /p will take care of closing it). – the_lotus Nov 19 '13 at 16:15

2 Answers2

0

You cannot. You call the Adobe Reader and another process, another program is opened. Nothing that you can do anymore but killing the task.

But the problem with killing the task is that you possibly it will close another PDF file opened after your print file be opened in the new instance of Adobe Reader.

I think that's OK in a custom software or in a closed and known environment of users if you choose to kill the Adobe process. But the users should be warned about this behavior. By manual of software or user training.

Andre Figueiredo
  • 12,930
  • 8
  • 48
  • 74
0

I used this to send a pdf to the standard printer

        Dim pd As New System.Drawing.Printing.PrintDocument

        Dim p As New PrintDialog()
        p.SelectedPagesEnabled = False

        If p.ShowDialog() = True Then

            pd.DocumentName = pdfFile
            pd.PrinterSettings.PrinterName = p.PrintQueue.Name
            pd.PrintController = New System.Drawing.Printing.StandardPrintController()
            pd.OriginAtMargins = False
            pd.Print()

        End If

Maybe works for you you too.

David Sdot
  • 2,343
  • 1
  • 20
  • 26