Silently Print PDF files (1 Viewer)

lespritdelescalier

Registered User.
Local time
Today, 06:38
Joined
Mar 16, 2015
Messages
50
Hello!

I am using Access 2010, and trying to print out multiple external PDF files silently (without opening Adobe Reader or a print dialog). I am not generating the PDFs with the Access DB - they are created by another application and stored on a network drive.

I've done a bunch of searches both online and on this forum, but I haven't happened upon anything helpful. Do I need a full version of Acrobat/Distiller to do this?

Silent printing is a requirement for this project, as the application will be printing out hundreds of documents an hour.

Thank you for any assistance you can provide!
 

lespritdelescalier

Registered User.
Local time
Today, 06:38
Joined
Mar 16, 2015
Messages
50
Thanks - I tried this one, but it starts the PDF viewer every time i click print.
 

isladogs

MVP / VIP
Local time
Today, 14:38
Joined
Jan 14, 2017
Messages
18,236
AFAIK arnel's code is very similar to that supplied by Albert Kallal except it loops through multiple files
Both use Shell, Namespace and InvokeVerb("Print")

As the PDF files are not being created in Access, I'm not sure why you are trying to print them using Access, 'silently' or otherwise.
Is it just because you have stored the file paths in Access?

Have you considered looking at other PDF software apart from Acrobat & Distiller which are VERY expensive

For example look at Foxit PDF: https://www.foxitsoftware.com/pdf-reader/view-print-pdf

They offer free solutions as well as other features in full commercial apps & are much cheaper I believe.

In addition most browsers can open PDFs natively including Edge & Chrome.
Not sure about Firefox

UPDATE:
Just found this code that might be adaptable for your use - place in a standard module

Code:
Option Compare Database
Option Explicit

'http://www.vbforums.com/showpost.php?p=3541686&postcount=2

Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Private Const SW_HIDE As Long = 0
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMINIMIZED As Long = 2
Private Const SW_SHOWMAXIMIZED As Long = 3 

Private Sub printIt(sFullFilename as string)
  Dim PrintIt As Long
  PrintIt = ShellExecute(Me.hwnd, "PRINT", sFullFilename , "", "", SW_SHOWNORMAL)
End Sub

I believe this will work by opening the default file handler for PDFs
So if you use SW_HIDE instead of SW_SHOWNORMAL it should work 'silently' for one file (not tested)
If so, just add a looping procedure to run through all your files in turn

HTH
 
Last edited:

lespritdelescalier

Registered User.
Local time
Today, 06:38
Joined
Mar 16, 2015
Messages
50
Thank you for your help looking in to this.

As the PDF files are not being created in Access, I'm not sure why you are trying to print them using Access, 'silently' or otherwise.
Is it just because you have stored the file paths in Access?
The Access application creates other documents which are being printed, so I was just hoping to have one program print everything.

Have you considered looking at other PDF software apart from Acrobat & Distiller which are VERY expensive

For example look at Foxit PDF: https://www.foxitsoftware.com/pdf-reader/view-print-pdf
My company owns licenses of Acrobat and Distiller. They'd just have to allocate one of those licenses to be used for this application if we decided to go that route. We also have a version of Foxit as well.

Just found this code that might be adaptable for your use - place in a standard module
Even with "SW_HIDE" as a parameter, the pdf reader is loading. I think that this is because Shell.Execute doesn't have any way of telling the application what kind of file is being printed, and therefore has to open the default program for the printed filetype before printing.

Also, at least the call needs to be placed on a form, as one of the parameters is hwnd, which from what I understand doesn't exist in a standard module.
 

isladogs

MVP / VIP
Local time
Today, 14:38
Joined
Jan 14, 2017
Messages
18,236
My company owns licenses of Acrobat and Distiller. They'd just have to allocate one of those licenses to be used for this application if we decided to go that route. We also have a version of Foxit as well.

Even with "SW_HIDE" as a parameter, the pdf reader is loading. I think that this is because Shell.Execute doesn't have any way of telling the application what kind of file is being printed, and therefore has to open the default program for the printed filetype before printing.

The default PDF program has to load in order to print the files. The reason I suggested using that code with SW_HIDE or possibly SW_MINIMIZED was so it could happen in the background whilst you got on with other tasks

As you could have the use of Acrobat/Distiller, that may be your best bet. However, I still believe the app will need to be opened even if it's in the background. Suggest you check on an Adobe forum.

Of course if the volume of docs to be printed is that large, using a dedicated workstation just for printing these files may be a better solution.
 

Users who are viewing this thread

Top Bottom