View Full Version : VB and iTextSharp to Print PDFs


txgeekgirl
06-02-2010, 06:37 AM
Anyone out there using VB and iTextSharp for generating PDFs inside a VB program? :D

I have a question with printing the pdf doc once it is made. Is it possible to call the pdf to print through VB or even with the iTextSharp lib?

I have found many forums where the same question is asked but most of the stuff is old and based on other languages. One of the biggest issues on these boards is whether PDF Reader auto closes. I don't care if my EUs have to click an "X" and would actually prefer them to have to interact with the Reader so that they can choose their network printer.

iTextSharp use to have a pretty good forum and website until about 3 weeks ago. They locked it all down and topics are hard to find.

Any help is appreciated.

ghudson
06-15-2010, 07:12 AM
See if my VBA solution I listed in this thread will work for you in VB... Print a PDF File (http://www.access-programmers.co.uk/forums/showthread.php?t=189181)

Look at my last post for I also list code to close Adobe.

txgeekgirl
07-07-2010, 06:00 AM
Here is the code I used and it's great.


If acroFiles.Length > 0 Then
Dim newreader As String = acroFiles(0) 'DO NOT MOVE ON THE FLY
Dim ps As Process = Process.Start(newreader, String.Format("/p ""{0}""", pdfFileToPrint)) 'DO NOT MOVE ON THE FLY
ps.WaitForExit()
Else
MessageBox.Show("Could not find Acrobat Reader program.")
End If

txgeekgirl
07-07-2010, 07:00 AM
GHudson - I actually emailed Bob Larson this morning regarding your very code because I was wondering how much I actually needed. What could I strip out? He could not help as he used it for something different.

The app I have built out is for a signature pad in VB.NET and using iTextSharp to build the PDF. It is VERY touchy about every thing I do and I don't want to break it.

It won't recognize the Private Const (throws errors) and having all of the Functions where I need them - it freaks out because all of the code HAS TO sit inside a Function called PenDown which has hidden implementation written by the manufacturer and I am not privy to their code.

I could remove the
ps.WaitForExit()
but it would be sloppy via RDP connection and could leave multiple instances of Adobe Reader running in the background and eat my server resorces.