Solved

Printing PDF Programatically knowing when acrobat is finished

Posted on 2011-03-10
5
445 Views
Last Modified: 2012-05-11
I am using the following code which I got on EE.   I have aloop reading through a textbox that has the full path and name of the file ie:

E:\991222\PT00002.pdf
E:\991222\PT00003.pdf
E:\991222\PT00004.pdf

I read each file and first print out a banner sheet with the information on the file.  I then need to print the file and I am using the following code:
 
  Dim p As New System.Diagnostics.ProcessStartInfo()
        p.Verb = "print"
        p.WindowStyle = ProcessWindowStyle.Normal
        p.FileName = filestring
        p.UseShellExecute = True
        System.Diagnostics.Process.Start(p)

Whats happening is because the banner sheets are quick and the acrobat files take a while it is not going in order.  I need to somehow monitor the acrobat file and then send the next file after it is complete.  

Your help is appreciated.
0
Comment
Question by:rphilipson
  • 3
  • 2
5 Comments
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35103203
Hi,

You can do it like this

0
 
LVL 13

Accepted Solution

by:
gamarrojgq earned 500 total points
ID: 35103212
Sorry, here it is the code
Dim p As New System.Diagnostics.ProcessStartInfo()
	Dim objProcess As System.Diagnostics.Process
        Try

            p.Verb = "print"
            p.WindowStyle = ProcessWindowStyle.Normal
            p.FileName = filestring
	    p.UseShellExecute = True

            objProcess = New System.Diagnostics.Process()
            objProcess.StartInfo = p
            objProcess.Start()

            'Wait until the process passes back an exit code 
            objProcess.WaitForExit()

            'Free resources associated with this process
            objProcess.Close()
        Catch
            MessageBox.Show("Could not start process ", "Error")
        End Try

Open in new window

0
 

Author Comment

by:rphilipson
ID: 35112483
In my print queue it is not in the order I sent it to print.  I think there must be a delay on the waitforexit.  Is there a way to easily check the queue and see if the file PT00002.pdf is in the queue before continuing.  Thanks
0
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35112530
Well if you want to check the printer queue, here is a link where explain the topic

http://www.codeproject.com/KB/printing/printwatchvbnet.aspx
0
 

Author Closing Comment

by:rphilipson
ID: 35782538
havent tried it yet
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question