Re: Auto printing PDF files
To programatically print PDF's you are pretty much stuck to using a 3rd party product, such as Adobe Reader. PDF-Xchange & Foxit also allow printing from the command line if you dont like Adobe, but with any of them you need to have the product installed on the machine that will be doing the printing.
Re: Auto printing PDF files
This should work for you. Use this to call
VB Code:
Try
Print.PrintPDF("C:\mypdffile.pdf")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
This
VB Code:
Imports System.IO
Imports System.Runtime.InteropServices
Public Class Print
Private Const SW_SHOWNORMAL As Integer = 2
<DllImport("shell32")> _
Private Shared Function ShellExecute(ByVal hWnd As IntPtr, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Integer) As IntPtr
End Function
Public Shared Sub PrintPDF(ByVal FilePath As String)
If IO.File.Exists(FilePath) Then
If ShellExecute(CType(1, IntPtr), "Print", FilePath, "", _
Directory.GetDirectoryRoot(FilePath), SW_SHOWNORMAL).ToInt32 <= 32 Then
Throw New Exception("Error: The file did not print.")
End If
Else
Throw New Exception("Error: The file does not exist.")
End If
End Sub
End Class
After reading nbrege's post I am wondering if I misunderstood the original request. Are you trying to do this without having Adobe (or equivalent) installed on the client machines?
Re: Auto printing PDF files
Actually I was asking if it could be done without Adobe, or third party software, installed.
If I have to use third party software then Adobe is fine. Can I handle errors in the background? We have an older VB6 program that is used currently and it runs into problems if there is anything wrong with the PDF file. An Abobe message pops up waiting for user to respond and the program stops functioning.