Open & print selected pages of PDF document

J

Jeff

Does anyone know if it's possible to use Access vba to automate the
printing of selected pages of a PDF file?

Here's the situation: I have a database of maintenance procedures.
Each procedure is a separate multiple-page PDF file. The technician
must fill in and sign the first page(s) each time the work is done. I
want to keep hard copies of the whole instructions in binders and save
paper by printing only the pages that need to be filled in each time
the work is done. Usually it's only one page, but could be 2 or 4.

My database has a form with a listbox of procedures. Currently, I'm
using Application.FollowHyperlink to open the PDF of the selected
procedure. The user can print the desired pages from Acrobat. But when
printing pages from many different files, it would save a lot of time
it I could select the desired file on the form and click a button to
send only the needed pages directly to a printer - instead of opening
and manually printing the needed pages from each document. I could
store the needed page number(s) in the database and send as a
parameter with the print instruction. I have searched but can't find a
way to do this and don't know if it's possible.

Workarounds I've considered:
1. Print large numbers of the needed pages and keep them on file.
Problem is - the procedures are revised periodically and the old
versions become obsolete and unusable. Time, paper, & storage space
wasted.

2. Have another copy of the PDF files with ONLY the needed pages; and
send those whole documents to the printer. Problem is - the PDF files
are secured and password protected so pages can't be extracted or even
printed to another PDF file.

3. Print needed pages to tif files with MS Document Image Writer.
Import images into a Word or PDF document (one for each procedure) and
use vba code to send document to printer. This works but takes a lot
of time & effort and there are hundreds of files. Also, it would have
to be re-done each time a new revision comes out.

Even if someone could tell me that it would be impossible (or very
difficult for an amateur like me to implement), at least I could stop
scratching my head and wondering if I've missed something simple.
Thanks!
 
J

James A. Fortune

Does anyone know if it's possible to use Access vba to automate the
printing of selected pages of a PDF file?

Here's the situation:  I have a database of maintenance procedures.
Each procedure is a separate multiple-page  PDF file.  The technician
must fill in and sign the first page(s) each time the work is done.  I
want to keep hard copies of the whole instructions in binders and save
paper by printing only the pages that need to be filled in each time
the work is done. Usually it's only one page, but could be 2 or 4.

My database has a form with a listbox of procedures. Currently, I'm
using Application.FollowHyperlink to open the PDF of the selected
procedure. The user can print the desired pages from Acrobat. But when
printing pages from many different files, it would save a lot of time
it I could select the desired file on the form and click a button to
send only the needed pages directly to a printer - instead of opening
and manually printing the needed pages from each document. I could
store the needed page number(s) in the database and send as a
parameter with the print instruction. I have searched but can't find a
way to do this and don't know if it's possible.

Workarounds I've considered:
1. Print large numbers of the needed pages and keep them on file.
Problem is - the procedures are revised periodically and the old
versions become obsolete and unusable. Time, paper, & storage space
wasted.

2. Have another copy of the PDF files with ONLY the needed pages; and
send those whole documents to the printer. Problem is - the PDF files
are secured and password protected so pages can't be extracted or even
printed to another PDF file.

3. Print needed pages to tif files with MS Document Image Writer.
Import images into a Word or PDF document (one for each procedure) and
use vba code to send document to printer. This works but takes a lot
of time & effort and there are hundreds of files. Also, it would have
to be re-done each time a new revision comes out.

Even if someone could tell me that it would be impossible (or very
difficult for an amateur like me to implement), at least I could stop
scratching my head and wondering if I've missed something simple.
Thanks!

Try the following:

http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACReference.pdf

http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/reader/pdfs/reader_overview.pdf

I have not tried to automate Adobe Reader, but a search string of
'acrobat reader automation' brought up some sample code.

James A. Fortune
(e-mail address removed)
 
J

Jeff

Thanks for the reply! A quick glance at the links you provided tells
me there must be a way to do what I'm trying to do. At this point, I'm
not sure if it's too much over my head or how to begin implementing it
in access vba . I'll have to spend some time studying it. Thanks
again!
 
D

David-W-Fenton

Does anyone know if it's possible to use Access vba to automate
the printing of selected pages of a PDF file?

Seems like you could do it with Application.FollowHyperlink and the
Adobe Reader commandline options, outlined here:

http://www.robvanderwoude.com/commandlineswitches.php#Acrobat

I tried this, and it worked:

AcroRd32.exe /A "page=7=OpenActions" PdfFile

The only tricky part, of course, is getting the embedded double
quotes in the commandline string that you pass to FollowHyperlink.
 
J

Jeff

Seems like you could do it with Application.FollowHyperlink and the
Adobe Reader commandline options, outlined here:

http://www.robvanderwoude.com/commandlineswitches.php#Acrobat

I tried this, and it worked:

AcroRd32.exe /A "page=7=OpenActions" PdfFile

The only tricky part, of course, is getting the embedded double
quotes in the commandline string that you pass to FollowHyperlink.
=============
Thanks. That looks like it would work to open the file to the
specified page. I wonder if combining the switches will allow me open
- print the correct page(s) - and then close the document. I will try
it out when I get to work tomorrow.
 
D

David-W-Fenton

=============
Thanks. That looks like it would work to open the file to the
specified page. I wonder if combining the switches will allow me
open - print the correct page(s) - and then close the document. I
will try it out when I get to work tomorrow.

You might check if there are DDE options for this. A promising but
frustrating piece of documentation is here:

http://acrobat-dde.nnn2.com/

One problem I've seen though, is a failure to distinguish Acrobat
from the Reader.

I would also check to see if FoxitReader is better provisioned here,
though getting it installed for your users could be a problem.
 
J

Jeff

You might check if there are DDE options for this. A promising but
frustrating piece of documentation is here:

http://acrobat-dde.nnn2.com/

One problem I've seen though, is a failure to distinguish Acrobat
from the Reader.

I would also check to see if FoxitReader is better provisioned here,
though getting it installed for your users could be a problem.


Concur with your description "promising but frustrating."
It looks like there must be a way to make it work, but it eludes me.
As my programming skills are essentially nonexistent, I will have to
wait until I find some working code that I can past into my database.

FoxitReader or any other program is not an option because I have no
control over the standard software installed on all the organization's
computers.

The best workaround I've found is to save the first page(s) of each
document as an .mdi file using MS Document Writer. I have 2 buttons on
the Access form: one using Application.FollowHyperlink to open the PDF
file - and the other uses Shell to print the mdi file to the default
printer. It prints in the background without opening the program.

It works exactly like I wanted. The only drawback is that I have to be
very careful to ensure that every time a new version of a PDF file is
received, the MDI file gets updated to match it.

Jeff Beverly
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top