printing PDF silently

Status
Not open for further replies.

catbollu2

New member
Joined
Sep 22, 2008
Messages
4
Programming Experience
Beginner
Hello
I am trying to print a PDF file to default printer without user seing this. I am using vb.net
This is the code I have tried and it will open the pdf file if you put open instead of print BUT if you put print it says.
"System.ComponentModel.Win32Exception: No application is associated with the specified file for this operation

at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)

at System.Diagnostics.Process.Start()

at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)

at TransUnion.TransUnion.MainRun()
"
VB.NET:
'Dim MyProcess As New Process
                'MyProcess.StartInfo.FileName = "C:\TransUnionReports\Credit\" + indexnm(x) + "-" + first(x) + "-" + last(x) + "-CreditReport.pdf"
                'MyProcess.StartInfo.Verb = "Open"
                'MyProcess.StartInfo.Verb = "Print"
                'MyProcess.Start()
I have also used the following code with the same error

VB.NET:
Dim psi As New ProcessStartInfo
                psi.UseShellExecute = True
                psi.Verb = "print"
                psi.WindowStyle = ProcessWindowStyle.Hidden
                psi.FileName = "C:\TransUnionReports\Credit\" + indexnm(x) + "-" + first(x) + "-" + last(x) + "-CreditReport.pdf"
                Process.Start(psi)
Does anyone know how to print a PDF using VB
 

Stonkie

Well-known member
Joined
Sep 12, 2007
Messages
279
Programming Experience
1-3
A quick google search tells me you either use adobe reader and ask it to print it : Forums at DNzone.COM

Or you use the Adobe SDK which seems to be free and read the docs to find a way to make it silent... Now, on the download page, there are words like "Geospatial features" and "PRC data contained in 3D annotations" and I got no idea what that all means... But if it gets you into space I guess it should print a pdf document :confused:
 

Stonkie

Well-known member
Joined
Sep 12, 2007
Messages
279
Programming Experience
1-3
I just ran the following code and it worked perfectly.

VB.NET:
        Try
            Dim MyProcess As New Process
            MyProcess.StartInfo.CreateNoWindow = False
            MyProcess.StartInfo.Verb = "print"
            MyProcess.StartInfo.FileName = "C:\Notessaethseeh.pdf"
            MyProcess.Start()
            MyProcess.WaitForExit(10000)
            Try
                MyProcess.CloseMainWindow()
                MyProcess.Close()
            Catch ex As Exception

            End Try
        Catch ex As Exception
            MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

Do you have Adobe Reader installed? Maybe you have another application associated with pdf files? Are you sure your default printer is the one you look at?
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,553
Location
Sydney, Australia
Programming Experience
10+
how to create pdf by itext and print pdf silently ..
This thread is specifically about the printing part. That means that the first part of your question is irrelevant to this thread and the second part has already been addressed. It's best not to resurrect 13 year old threads anyway. Create a new thread and post a link to the existing one if doing so adds value.
 

damini jha

New member
Joined
Aug 2, 2021
Messages
2
Programming Experience
1-3
I want to print my pdf silently but .. by this method my pdf is opening by itself ... i don't want any preview of my pdf ... just want to print
 
Status
Not open for further replies.
Top Bottom