473,796 Members | 2,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Print PDF File

Hi,

I'm looking for a component or code which will allow me to print an existing PDF file
from a VB.NET app.

I need the ability to specify the PDF file and the printer name on which it is to
print, then have the document, er, print.

That's it.

I've tried google, but all I've found are many (many) products which will do all
sorts of things like convert files to PDF as well as print them. They are full
featured applications to do way, way more than I need.

I already have the PDF files, I just need the ability for a user to identify the
document he wants to print, and where to print it.

Can anyone offer some suggestions?

Thanks,
Nov 21 '05 #1
3 11548
To print a PDF document, you can use this code:

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim myProcess As Process = New Process
'myProcess.Star tInfo.WindowSty le = ProcessWindowSt yle.Hidden
myProcess.Start Info.FileName = "C:\!emoreau_mi sc\Doc\UG-Gestion des
utilisateurs.pd f"
myProcess.Start Info.Verb = "Print"
myProcess.Start Info.UseShellEx ecute = True
myProcess.Start ()
myProcess.WaitF orInputIdle()

If myProcess.Respo nding Then
myProcess.Close MainWindow()
Else
myProcess.Kill( )
End If
End Sub

You can read my article of December 2003 titled "The Process component" from
http://emoreau.s2i.com/.

To select a printer, I have another article : "Setting Windows default
printer" (March 2005)

--
HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
(http://aspnet2.com/mvp.ashx?EricMoreau)
Conseiller Principal / Senior Consultant
Concept S2i inc. (www.s2i.com)
http://pages.videotron.com/emoreau/

"Jeff Mason" <je******@comca st.net> wrote in message
news:t1******** *************** *********@4ax.c om...
Hi,

I'm looking for a component or code which will allow me to print an
existing PDF file
from a VB.NET app.

I need the ability to specify the PDF file and the printer name on which
it is to
print, then have the document, er, print.

That's it.

I've tried google, but all I've found are many (many) products which will
do all
sorts of things like convert files to PDF as well as print them. They are
full
featured applications to do way, way more than I need.

I already have the PDF files, I just need the ability for a user to
identify the
document he wants to print, and where to print it.

Can anyone offer some suggestions?

Thanks,

Nov 21 '05 #2
On Fri, 14 Oct 2005 11:44:20 -0400, "Eric Moreau"
<er************ *********@video tron.ca> wrote:
To print a PDF document, you can use this code:

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventAr gs) Handles Button1.Click
Dim myProcess As Process = New Process
'myProcess.Sta rtInfo.WindowSt yle = ProcessWindowSt yle.Hidden
myProcess.Star tInfo.FileName = "C:\!emoreau_mi sc\Doc\UG-Gestion des
utilisateurs.p df"
myProcess.Star tInfo.Verb = "Print"
myProcess.Star tInfo.UseShellE xecute = True
myProcess.Star t()
myProcess.Wait ForInputIdle()

If myProcess.Respo nding Then
myProcess.Clos eMainWindow()
Else
myProcess.Kill ()
End If
End Sub

You can read my article of December 2003 titled "The Process component" from
http://emoreau.s2i.com/.

To select a printer, I have another article : "Setting Windows default
printer" (March 2005)


Thanks.

I am aware of the method using ShellExecute. One problem with this for me is that
this presumes that some suitable renderer for the PDF file has been previously
installed on the system and that an appropriate file association has been set up, so
this method requires Acrobat or something like it. Another is that requests will
come from users asking that a given document be printed on a printer specified by the
user. This would mean that I would have to mess with setting the default printer,
which is ugly at best, IMO. I've never seen a satisfactory solution to this issue
either, since it requires the Windows Scripting Host. Yuck.

I'm looking for a solution that doesn't involve Acrobat or the Reader, if possible,
though I admit I didn't state so.

The main issue with Acrobat, et al, is that the code which will be doing the printing
will run on a server, and as I understand it, Adobe licenses don't allow Acrobat to
be used that way.

My Google searches have turned up many products wich will print a PDF file, among a
whole lot of extraneous (for my purposes) features, so it is clear that Acrobat is
not needed to print a PDF.

What is?
Nov 21 '05 #3

"Jeff Mason" <je******@comca st.net> wrote in message
news:38******** *************** *********@4ax.c om...
On Fri, 14 Oct 2005 11:44:20 -0400, "Eric Moreau"
<er************ *********@video tron.ca> wrote:
To print a PDF document, you can use this code:

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventA rgs) Handles Button1.Click
Dim myProcess As Process = New Process
'myProcess.St artInfo.WindowS tyle = ProcessWindowSt yle.Hidden
myProcess.Sta rtInfo.FileName = "C:\!emoreau_mi sc\Doc\UG-Gestion des
utilisateurs. pdf"
myProcess.Sta rtInfo.Verb = "Print"
myProcess.Sta rtInfo.UseShell Execute = True
myProcess.Sta rt()
myProcess.Wai tForInputIdle()

If myProcess.Respo nding Then
myProcess.Clo seMainWindow()
Else
myProcess.Kil l()
End If
End Sub

You can read my article of December 2003 titled "The Process component"
from
http://emoreau.s2i.com/.

To select a printer, I have another article : "Setting Windows default
printer" (March 2005)


Thanks.

I am aware of the method using ShellExecute. One problem with this for me
is that
this presumes that some suitable renderer for the PDF file has been
previously
installed on the system and that an appropriate file association has been
set up, so
this method requires Acrobat or something like it. Another is that
requests will
come from users asking that a given document be printed on a printer
specified by the
user. This would mean that I would have to mess with setting the default
printer,
which is ugly at best, IMO. I've never seen a satisfactory solution to
this issue
either, since it requires the Windows Scripting Host. Yuck.

I'm looking for a solution that doesn't involve Acrobat or the Reader, if
possible,
though I admit I didn't state so.

The main issue with Acrobat, et al, is that the code which will be doing
the printing
will run on a server, and as I understand it, Adobe licenses don't allow
Acrobat to
be used that way.


That is my understanding too.

You need either a PDF renderer, or a translator to translate PDF to a
language supported by your printer.

I had this same issue and here's the best tool I could find: XPDF
Xpdf is an open source viewer for Portable Document Format (PDF)
files. (These are also sometimes also called 'Acrobat' files, from the name
of Adobe's PDF software.) The Xpdf project also includes a PDF text
extractor, PDF-to-PostScript converter, and various other utilities.


http://www.foolabs.com/xpdf/download.html

This included a command line tool pdftops which will transform a PDF file to
a Postscript file. The postscript file can then be copied to a postscript
printer.

David
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2437
by: Manfred Schwab | last post by:
Recording messages and print statements in a textfile during program execution. Is there a similar command to redirect errormessages or print statements into a standart asciifile during programm execution. I would like to echo the complete console output into a textfile and send this file as email at a certain point in time. The programm execution shall not be stopped.
1
5724
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out of a Microsoft book, "Visual Basic,Net Step by Step" in Chapter 18. All but the bottom two subroutines will open a text file, and then allow me to use the above controls, example 1. The bottom two subroutines will print a graphic file, example...
7
2642
by: Ron | last post by:
Hi All, Is it possible to have Access print a report, identical to one that would print to a printer, only print to a "standard" text file? I can't find it in help and when I try to just print to a file (in the printer selection screen of the print routines) it gives me a file named what I wanted, but is just garbage. Can't read it. TIA ron
3
2344
by: Max58kl | last post by:
Trying to access data and print it to the screen using Perl Builders I/O Window -------------------------------------------------------------------------------- Hi I am using a program called Perl Builder which is an Integrated Development Environment for Perl scripting. I am trying to access the data in a txt file and then print the results to the screen. The procedure for doing this is write a script then click on the Run button,...
3
2438
by: itdaddy | last post by:
hey perl gurus! i am new to this forum cause i need help. I have done many scripts. but i want to use perl to do this: What I want to do is this. I have a QRP file that I can convert to a txt file field separated by commas or not. I want to pring each line that has an actual date to the right of the word 'DATE:' if it doesnt have a date do not print that line. Then the next thing i want my perl program to do is print each line that has...
2
2705
by: alivip | last post by:
when I wont to inser (anyting I print) to the textbox it will not inser it just print then hanging # a look at the Tkinter Text widget # use ctrl+c to copy, ctrl+x to cut selected text, # ctrl+v to paste, and ctrl+/ to select all # count words in a text and show the first ten items # by decreasing frequency
12
3543
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to print the report three times, but do not know how
5
13685
by: prakashturkar | last post by:
Hi, I am Prakash.... I have tried to print an MS Word file using the basic print utilities provided in JAVA.But while asking for printing through my own code i am getting proble for example..."The given flavour is not supported by utility" and still if i got an printout ,so.. it was not in well formate like the actual MS word File.Please help me to solve this problem.The folowing is the code that i have used to print MS Word File. package...
2
2105
by: dmorand | last post by:
When I try to print a 'print version' of my page it looks fine in IE 7, but when I print in IE 6 the margins are all screwed up. The page itself looks the same in both browsers, it's just when I print the elements look bigger when I print from IE 6 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta...
11
4220
by: JWest46088 | last post by:
I'm having difficulty trying to figure out how to print a text file from a hash table one line at a time. I have the text file read into the hash table and can print the text file all at once, but I can't seem to figure out how to do it one line at a time. Here is what I'm trying to do: I want the user to be able to print the text file one line at a time by clicking a button to see the next line. Example: If text_file1 first line is...
0
10459
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10187
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10018
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.