Forums

Overview » VB .NET » Printing a pdf/word file in vb.net not using com
Reply

Printing a pdf/word file in vb.net not using com

P.R Anish
Newbie



Since: 24 Feb 2004
Posts: 1
Posted 25 Feb 2004 13:22:08

hi ,

I need help for printing pdf and word file using vb.net . the component should be a pure donet componet not a com component.
I have to open the pdf and word file then I have to print it .
If Any body know pls let me know .



Edited by - anish_p_r on 25 Feb 2004 13:25:40

Edited by - anish_p_r on 25 Feb 2004 13:26:23

hi ,

I need help for printing pdf and word file using vb.net . the component should be a pure donet componet not a com component.
I have to open the pdf and word file then I have to print it .
If Any body know pls let me know .



Edited by - anish_p_r on 25 Feb 2004 13:25:40

Edited by - anish_p_r on 25 Feb 2004 13:26:23
Ripal Soni
Newbie



Since: 10 Mar 2006
Posts: 4
Replied 10 Mar 2006 23:06:24
Hi,
You can use process to print pdf file in .net
the code is simply like
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.Verb = "print"
psi.WindowStyle = ProcessWindowStyle.Hidden
psi.FileName = sReport
Process.Start(psi)
it will print pdf file ,you don't need any extra component for this
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
hi ,

I need help for printing pdf and word file using vb.net . the component should be a pure donet componet not a com component.
I have to open the pdf and word file then I have to print it .
If Any body know pls let me know .



Edited by - anish_p_r on 25 Feb 2004 13:25:40

Edited by - anish_p_r on 25 Feb 2004 13:26:23
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Ic Tech Support
Newbie



Since: 01 Jun 2006
Posts: 1
Replied 01 Jun 2006 21:30:39
Hi Ripal Soni...

The code you gave works great.. But one question, How would you close the Acrobat Windows after the printing is done?
Wouter De Wilde
Newbie



Since: 05 Sep 2006
Posts: 1
Replied 05 Sep 2006 18:01:30
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi Ripal Soni...

The code you gave works great.. But one question, How would you close the Acrobat Windows after the printing is done?
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I would love to know the answer to this question...

Edited by - Snipe on 05 Sep 2006 18:01:49
Prog Gad
Newbie



Since: 18 Oct 2006
Posts: 1
Replied 18 Oct 2006 00:07:02
To close Acrobat Windows I wrote this code

Dim MyProcess As New Process
MyProcess.StartInfo.CreateNoWindow = False
MyProcess.StartInfo.Verb = "print"
MyProcess.StartInfo.FileName = "C:\Test.pdf"
MyProcess.Start()
MyProcess.WaitForExit(10000)
MyProcess.CloseMainWindow()
MyProcess.Close()

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi Ripal Soni...

The code you gave works great.. But one question, How would you close the Acrobat Windows after the printing is done?
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I would love to know the answer to this question...

Edited by - Snipe on 05 Sep 2006 18:01:49
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

prog_ga
Borja Gil
Locked
Newbie



Since: 20 Dec 2006
Posts: 1
Replied 20 Dec 2006 13:25:08
Hello everyone, and sorry for my english.

Is any way to modify the .pdf archive, in the example: Test.pdf, and then print it??? I want to made some changes on it, and then see them when I print

Thank you, and sorry again for my english



<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
To close Acrobat Windows I wrote this code

Dim MyProcess As New Process
MyProcess.StartInfo.CreateNoWindow = False
MyProcess.StartInfo.Verb = "print"
MyProcess.StartInfo.FileName = "C:\Test.pdf"
MyProcess.Start()
MyProcess.WaitForExit(10000)
MyProcess.CloseMainWindow()
MyProcess.Close()

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi Ripal Soni...

The code you gave works great.. But one question, How would you close the Acrobat Windows after the printing is done?
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I would love to know the answer to this question...

Edited by - Snipe on 05 Sep 2006 18:01:49
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

prog_ga
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Sonia Singh
Newbie



Since: 04 Jan 2007
Posts: 1
Replied 04 Jan 2007 09:39:44
I am also struggling with the same problem of printing DOC as well as PDF files from VB 6.0 or VB.Net code with manipulating the printer settings from the code like - paper size, layout, bin, color mode, scaling etc.

Please somebody help.......I need it urgently

Best Regards,
Sonia &lt; &gt;
Subhadip Datta
Locked
Newbie



Since: 14 Apr 2007
Posts: 2
Replied 14 Apr 2007 14:26:43
It is working fine but it is printing at the default printer. How could i print the pdf file giving printer name?

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
hi ,

I need help for printing pdf and word file using vb.net . the component should be a pure donet componet not a com component.
I have to open the pdf and word file then I have to print it .
If Any body know pls let me know .



Edited by - anish_p_r on 25 Feb 2004 13:25:40

Edited by - anish_p_r on 25 Feb 2004 13:26:23
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Subhadip Datta
Mumbai, India
Subhadip Datta
Locked
Newbie



Since: 14 Apr 2007
Posts: 2
Replied 14 Apr 2007 14:28:13
It is working fine but it is printing at the default printer. How could i print the pdf file giving printer name?

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
hi ,

I need help for printing pdf and word file using vb.net . the component should be a pure donet componet not a com component.
I have to open the pdf and word file then I have to print it .
If Any body know pls let me know .



Edited by - anish_p_r on 25 Feb 2004 13:25:40

Edited by - anish_p_r on 25 Feb 2004 13:26:23
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Subhadip Datta
Mumbai, India
Ripal Soni
Newbie



Since: 10 Mar 2006
Posts: 4
Replied 30 Apr 2007 19:26:47
To Print file on your selected printer instead of default printer you can write the following code
also you can find the complete solution in ripalsoni.wordpress.com/2007/04/25/print-pdf-file-in-vbnet-by-giving-printer-name/

Dim pathToExecutable As String = “AcroRd32.exe”

Dim sReport = “C:Test.PDF” ‘Complete name/path of PDF file

Dim SPrinter = “HP Officejet 5600 seriese” ‘Name Of printer

Dim starter As New ProcessStartInfo(pathToExecutable, “/t “ + sReport + ” “ + sPrinter + “”

Dim Process As New Process()

Process.StartInfo = starter Process.Start()

the above code will print your pdf file on the printer you want ,you can also print word document by the same way just change your executable file path from Acrobat32.exe to word exe

Thanks

Ripal Soni

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
It is working fine but it is printing at the default printer. How could i print the pdf file giving printer name?

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
hi ,

I need help for printing pdf and word file using vb.net . the component should be a pure donet componet not a com component.
I have to open the pdf and word file then I have to print it .
If Any body know pls let me know .



Edited by - anish_p_r on 25 Feb 2004 13:25:40

Edited by - anish_p_r on 25 Feb 2004 13:26:23
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Subhadip Datta
Mumbai, India
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Mohammed Ali
Locked
Newbie



Since: 06 Dec 2007
Posts: 1
Replied 06 Dec 2007 09:14:41
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi,
You gave the code for printing the pdf my requirement is same but prob here is with my appln is unable to start process of Process.Start(psi) could u plz help me out in this regard.

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi,
You can use process to print pdf file in .net
the code is simply like
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.Verb = "print"
psi.WindowStyle = ProcessWindowStyle.Hidden
psi.FileName = sReport
Process.Start(psi)
it will print pdf file ,you don't need any extra component for this
Quote
hi ,

I need help for printing pdf and word file using vb.net . the component should be a pure donet componet not a com component.
I have to open the pdf and word file then I have to print it .
If Any body know pls let me know .



Edited by - anish_p_r on 25 Feb 2004 13:25:40

Edited by - anish_p_r on 25 Feb 2004 13:26:23
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>


<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
eli mizrahi
Newbie



Since: 06 Mar 2008
Posts: 1
Replied 06 Mar 2008 17:10:50
hello

this code works but-
how do i open the printer's dialog box to select a printer ?



<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi,
You gave the code for printing the pdf my requirement is same but prob here is with my appln is unable to start process of Process.Start(psi) could u plz help me out in this regard.

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi,
You can use process to print pdf file in .net
the code is simply like
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.Verb = "print"
psi.WindowStyle = ProcessWindowStyle.Hidden
psi.FileName = sReport
Process.Start(psi)
it will print pdf file ,you don't need any extra component for this
Quote
hi ,

I need help for printing pdf and word file using vb.net . the component should be a pure donet componet not a com component.
I have to open the pdf and word file then I have to print it .
If Any body know pls let me know .



Edited by - anish_p_r on 25 Feb 2004 13:25:40

Edited by - anish_p_r on 25 Feb 2004 13:26:23
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>


<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Edited by - elim on 06 Mar 2008 19:17:43

Edited by - elim on 06 Mar 2008 19:18:06
KiranKumar Roy
Newbie



Since: 27 May 2008
Posts: 1
Replied 27 May 2008 15:56:34
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>

Hi Anish,

I am having a same problem which you have. i am using ASP.NET 2.0(C#) I need to print file
located at server.And that should be printed on my printer which is installed at server. I have
read this topic. I am doning a same code as you. If you got the solution for this then please
give me a solution. My code is working when I m debuging the code. And it gives


<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>


<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>


hi ,

I need help for printing pdf and word file using vb.net . the component should be a pure donet componet not a com component.
I have to open the pdf and word file then I have to print it .
If Any body know pls let me know .



Edited by - anish_p_r on 25 Feb 2004 13:25:40

Edited by - anish_p_r on 25 Feb 2004 13:26:23
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote><font face='Impact'></font id='Impact'><font face='Andale Mono'></font id='Andale Mono'><font face='Century Gothic'></font id='Century Gothic'><font face='Impact'></font id='Impact'><b></b>

KIRANKUMAR ROY

+91-9998847534
GaneshM M
Newbie



Since: 05 Aug 2008
Posts: 1
Replied 05 Aug 2008 16:38:21
Dear Ripal,
Below is the code in C# for printing PDF using network printer. The file is always printing in the default printer which is set in my machine. It should print in the network printer specified in the below path. Please let me know what could be the reason? and the solutio for this.. Thanks

String pathToExecutable = @"AcroRd32.exe" ;
String s1Reports= @"D:\TestDocs\PrintScreenUI.pdf";
String SPrinter= @"\\ccrnt008\HPLaser2F";
ProcessStartInfo starter = new ProcessStartInfo(pathToExecutable, "/t " + s1Reports + " " + SPrinter + " " ;
Process ps = new Process();
ps.StartInfo = starter;
ps.Start();
ps.WaitForExit(10000);
ps.CloseMainWindow();
ps.Close();
Donna Petersen
Newbie



Since: 05 Sep 2008
Posts: 1
Replied 05 Sep 2008 01:11:02

I am using this method to interface with SQL Reporting Services from my VB .net application. I create the report and copy it to a .pdf file in the temp folder. I want to print it or preview (and maybe print) and then delete the temp file.

I have tried the code suggested earlier to print the pdf and it works fine. I need to add the option to preview the doc. I added code to change the verb to "open" and that works. If I just look at it and close the window I am OK, but if I try to select the Print option on the form I get an error. "The process cannot access the file 'c:\myfile.pdf' because it is used by another process." I removed the WaitForExit and I dont get that error, but the app moves on to the code I have to clean up the temp file by deleting it and I get other errors. Any suggestions for handling a preview with a pdf?
Alex Krenvalk
Newbie



Since: 14 Jul 2010
Posts: 3
Replied 11 Nov 2010 07:50:51
My wife has quite big experience in computer sphere. But only she couldn't help in my trouble. I used the Inet and luckily observed there a good tool, which worked out my issue for seconds and would settle any question also - how can repair word doc.
raj thapa
Newbie



Since: 17 Apr 2013
Posts: 1
Replied 17 Apr 2013 08:07:49
i found this article very helful.and i am preety much impress with this. i want to print the document files and stop printer after last line print .can you guys tell me how can i do that
thanks in advance

Reply to this topic

Message
Reply
Follow us on twitter Subscribe to our RSS feed
Activate your free membership today | Login | Currency