VB and iTextSharp to Print PDFs (1 Viewer)

txgeekgirl

Registered User.
Local time
Today, 04:49
Joined
Jul 31, 2008
Messages
187
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

Registered User.
Local time
Today, 07:49
Joined
Jun 8, 2002
Messages
6,195
See if my VBA solution I listed in this thread will work for you in VB... Print a PDF File

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

txgeekgirl

Registered User.
Local time
Today, 04:49
Joined
Jul 31, 2008
Messages
187
Here is the code I used and it's great.

Code:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] acroFiles.Length > 0 [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] newreader [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = acroFiles(0) [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'DO NOT MOVE ON THE FLY
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ps [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Process = Process.Start(newreader, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Format([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"/p ""{0}"""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], pdfFileToPrint)) [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'DO NOT MOVE ON THE FLY
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]ps.WaitForExit()
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]MessageBox.Show([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Could not find Acrobat Reader program."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][/COLOR][/SIZE]
 

txgeekgirl

Registered User.
Local time
Today, 04:49
Joined
Jul 31, 2008
Messages
187
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
Code:
[SIZE=2]
ps.WaitForExit()
[/SIZE]
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.
 

Users who are viewing this thread

Top Bottom