Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing PDFs from a VB program

Status
Not open for further replies.

rjstsas

MIS
Apr 28, 2003
22
US
I have a VB program that prints all the PDFs in a directory. It works fine when run on my PC, but I need to have it available to everyone in my company. I created an EXE for the vb program on the network, but it does not work because adobe acrobat 6.0 standard and reader are not located on the network. Everyone has the reader installed on their pc's. Acrobat 6.0 will not install on a network drive either. I consider myself a VB virgin.
 

Did you make an install package for the users to install your program? Do they have reader installed on their computers?

If no to one or the other then you will have to either create your install package or the user will have to install the reader.

Good Luck

 
This should work its based on a similar routine Ive used before.

Add this to the Declaration section of the form, or make it public and add to a code module.

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long

Then use this code to loop thru a folder (in my example c:\_test) and print each pdf file

Dim sPath As String
Dim sFname As String
Const SW_HIDE = 0

sPath = "C:\_Test\"
sFname = Dir(sPath & "*.pdf", vbNormal)
Do Until sFname = ""
sFname = Chr(34) & sPath & sFname & Chr(34)
ShellExecute 0&, "Print", sFname, "/s/t", 0&, SW_HIDE
sFname = Dir()
Loop


Hope this helps.
 
The vb program is called from a Unix order processing system. The order can contain 1 or more requests for PDF documents. The goal is to have the unix program create a temporary directory with the PDF docs, pass the directory path to the vb program and the vb program print the PDFs in the directory. The hope is that a single copy of the vb program can sit on the network and when called by the unix program, it will run on their local pc to print the PDFs.
 

You will then need to install the required runtime files on each client that will use your program. You can do this by installing the program at each computer but directing the install location to be the common shared drive/directory, and each client will also need to have the adobe product installed.

Good Luck

 
I was hoping to use the Adobe APIs for printing the PDFs. The program runs great called from a common network drive by the unix program... as long as I have a full version of Adobe Acrobat installed on my PC... We can not afford to outfit everyone with the full version. The goal was to use reader to do the printing. The advange of using the APIs is that the program will only be opened once and them print many PDFs,... it looks like if I use reader and the code earlier submitted, that reader will open for each PDF I need to print... there has to be an easier way to print a bunch of PDFs at once.
 

You don't happen to have Adobe's SDK by any chance do you? There is some vb code that will show you how to open, print, and then close pdf's using reader.

Or using the above code with some other code you can control the number of adobe sessions that open up by controlling the printer spooler ...

Check Printer For Number of pending jobs
If number = 0 then
print pdf
else
wait on job count to = 0
end if

Good Luck

 
You got it ...because we are printing a whole directory of PDFs (could be as many as 100), we need a way to print a batch of PDF files quickly. If we just print using using reader, won't a new reader open for each PDF?

Hope was to use the APIs in the Standard version of Acrobat. The cobol program is the order entry process running on unix... the PDFs are the MSDS files requested by the customer. We have to print the order and MSDS files togeter. Cobol program creates a temp directory, fills it with the required PDF files and does a shell command to execute the vb program (if the vb program runs on the server where acrobat lives... all works great) and waits for VB program to delete one file in the temp directory. When the one file is gone, the cobol program deletes the temp directory and returns control to the user. Trying to minimize user impact and interaction. Each piece is working perfect.... just not together.
 

Ok if you have the 5.0 SDK you need to look in

..\Acrobat 5.0 SDK\InterAppCommunicationSupport\Samples\Visual Basic\ActiveView\ActiveView.vbp

This is an MDI application that will allow you to open and view and or print PDF's.

And no I don't think it will open multiple adobe products.

Good Luck

 
Yes we did... but we ended up going down a different route. We could not get the VB program to run using remote commands (ran fine when execute from the server). So, we found a $50 program on the web that will sit on a windows server, monitor a directory and print any file in the directory... this allows us to even print text or word files also. In addition, the software (latest beta) will monitor a directory for a job file - a list of stuff to print using the complete path - and then print the list of files in the job file. We will be using that featur in the next few weeks. We go live today. Additionally, it uses Adobe Reader instead of the VB API requirement of using Adobe Acrobat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top