Solved

Print PDF Files

Posted on 2013-12-27
12
1,749 Views
Last Modified: 2014-01-28
Hi,

I have about 100 PDF files that need to be printed each month.  I have an MS Access database table that lists the files.  What I would like to do is loop through the recordset and print each file without opening the file or at least automatically opening and closing the file.

Essentially, I want to print all 100 files with a single mouse click.

Any ideas?

Thanks in advance!

Bill
0
Comment
Question by:Bill Ross
  • 4
  • 4
  • 3
12 Comments
 
LVL 40

Assisted Solution

by:als315
als315 earned 250 total points
ID: 39743235
You can use Adobe Acrobat Reader for printing, but in this case you should know, where it is located. If you have static configuration, you can find exe and add path to code. For example, in Windows 7 x64 it is here:
c:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe
Use this sub in loop through all files from your table:
Sub print_pdf(FName As String)
Dim AcroPath As String
AcroPath = "c:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"
Shell (AcroPath & " /p /h " & Chr(34) & FName & Chr(34))
End Sub
'Call sample
Sub test()
print_pdf ("e:\Downloads\w_makb05.pdf")
End Sub

Open in new window

File will be printed on default printer
0
 
LVL 21
ID: 39743944
I find this works best.

CreateObject("Shell.Application").Namespace(0).ParseName("c:\mypdf\myDoc.pdf").InvokeVerb ("Print")

Open in new window


You do not have to know the path the the EXE. It will use the default PDF app. I use thia with Acrbat, Nitro and some others.
0
 
LVL 14

Author Comment

by:Bill Ross
ID: 39744036
Hi als315 & HiTechCoach,

Both options work OK but Adobe opens each time, prints then leaves itself open.  Takes forever to get the reports to print 10-15 sec.

Given this, my 100 document print job will take 20 minutes which is OK but the user must watch Adobe open/close, etc. and has a lot of "Not Responding" messages.  I think the users might quit out...

I would like a "silent" method where I can just put a progress bar on the screen and no Adobe flash.  Any ideas?

Thanks,

Bill
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 40

Expert Comment

by:als315
ID: 39744435
I think you can't get more with Adobe Acrobat Reader. May be you can try any third party solutions. You can get one here:
http://sourceforge.net/projects/ghostscript/files/GPL%20Ghostscript/
Help for command line options is included

Here is an article with how to for .net with code:
http://netchallenge.wordpress.com/2009/04/30/silent-printing-pdf-in-net-using-gsprint-and-additional-truetype-fonts/
0
 
LVL 21
ID: 39745593
If you are going to use Acrobat and want it silent then use /t not /p


AcroRd32.exe /t "C:\test.pdf" "\\servername\printername"


/t <filename> <printername> <drivername> <portname> - Print the file the specified printer.

Example:
Sub print_pdf(FName As String)

     Dim AcroPath As String

     AcroPath = "c:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"

     Shell (AcroPath & " /t " & Chr(34) & FName & Chr(34))
End Sub
'

Open in new window



You may also need to disable "Activate protected mode at startup"

  [HKEY_CURRENT_USER\Software\Adobe\Acrobat Reader\11.0\Privileged]
     "bProtectedMode"=dword:00000000

Open in new window


I generally avoid Acrobat Reader because ti loads so slow. I recommend to all my clients/users that they  use Nitro Reader.
0
 
LVL 14

Author Comment

by:Bill Ross
ID: 39746055
Hi Tech - Suppose I have the users install Nitro reader - how do I make sure it's used if they also have Adobe Reader and maybe even Adobe Pro installed?

als - Have you tried the Ghostscript process in VBA?
0
 
LVL 40

Expert Comment

by:als315
ID: 39746119
I've not tried to print many files, but one file is printed with similar to AcroReader code:
AcroPath = "c:\Program Files\Ghostgum\gsview\gsview64.exe"
Shell (AcroPath & " -p " & Chr(34) & FName & Chr(34))

Open in new window

0
 
LVL 21

Accepted Solution

by:
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 250 total points
ID: 39746408
BillDenver,

Did you try using the /t not the /p with Acrobat?

Suppose I have the users install Nitro reader - how do I make sure it's used if they also have Adobe Reader and maybe even Adobe Pro installed?

To use a specific app, not the default one, you will need to know the full path t tot he app. There are several ways to do this. Shell() is just one.  

One of the downsides using a specific app is that you need to know the full path the the exe. It is not the same for Acrobat reader and full Acrobat.. The path also varies by versions. I use a ini file on each machine to hold the settings. This allows me to configure the app on each workstation based on the software installed.
0
 
LVL 14

Author Comment

by:Bill Ross
ID: 39752715
Hi,

I am traveling this week.  I'm going to test the various solutions over the weekend to see what works best.  

Thanks!

Bill
0
 
LVL 21
ID: 39752941
Bill,

Thanks for the update.
0
 
LVL 14

Author Comment

by:Bill Ross
ID: 39767152
Hi Guys,

Sorry for the delay - I'm still on the road through next week and will test when I get back in the office.

Bill
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question