Groups | Blog | Home
all groups > vb.net controls > february 2007 >

vb.net controls : printing existing documents in vb.net 2005


Brad Pears
2/15/2007 12:44:24 PM
Printing in vb.net seems to be much more convoluted than it ever was
before...

I am having troubles finding "good" articles that really spell out the
complete printing process.

What I would like to see especially is the ability to print existing
documents (ie. Word, PDF, Excel etc...) from within a vb application.

I have a listview which lists filenames. I would like the user to be able to
select one or multiple items from the listview, right click and select a
'Print' option. I would then loop through the selected items and send them
to the default printer. I would like to be able to print the selected
documents in the correct formats - just as if you would using windows
explorer and selecting the 'Print' option when you right click an item.

Any ideas?

Thanks, Brad


Herfried K. Wagner [MVP]
2/16/2007 2:05:24 AM
"Brad Pears" <bradp@truenorthloghomes.com> schrieb:
[quoted text, click to view]

Printing files of various types without user interaction
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=printinganyfile&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
Brad Pears
2/16/2007 11:07:43 AM
Thanks for that... It works fine except that the associated application
launches as well... i.e when I print a .pdf file as shown in the example,
Adobe launches. Is there a way to prevent that from happening?

Thanks, Brad

[quoted text, click to view]

Brad Pears
2/16/2007 12:00:51 PM
Thanks for that... It works fine except that when printing a .pdf, Adobe
launches but does not close. I tried a word document, and Word launched, the
doc printed and word closed. But, for some reason, when I printed the .pdf,
Adobe launches and stays active - meaning the user has to manually close it.
Not a big deal - but a bit of a pain. Can you think of any way I might be
able to force Adobe to close - or even minimize?

Thanks, Brad

[quoted text, click to view]

Javier
3/1/2007 9:14:58 PM
Dim psi As New ProcessStartInfo()
With psi
.Verb = "print"
.WindowStyle = ProcessWindowStyle.Hidden
.FileName = "C:\filename.pdf"
.UseShellExecute = True
End With
Process.Start(psi)


AddThis Social Bookmark Button