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!

Controlling Adobe Acrobat 1

Status
Not open for further replies.

jastoneii

IS-IT--Management
May 19, 2003
3
US
One of our applications creates both text and pdf report files. We often need to batch print several hundred of these two kinds of files in a specific order. I wrote a .PRG to COPY FILE the text files and SHELLEXECUTE the pdf files as needed. I put wait() commands with timeouts after printing each type of file to ensure the files stay in order.

A couple weird things that I've noticed:

1. Adobe Acrobat or Acrobat Reader (which ever is on the machine) stays open after the print call via SHELLEXECUTE -- this is minor but may cause issue #2.

2. Fairly often a PDF file will print out prior to one or two other PDF files that were passed to acrobat first.

Anyone know how to call windows API functions to check on Adobe Acrobat's status? Or have any other suggestions?

TIA,

Jeff
 
jastoneii

The following code will close Adobe Reader if it exists

DECLARE INTEGER GetActiveWindow IN Win32API

DECLARE INTEGER GetWindowText IN Win32API;
[tab]INTEGER hWnd,;
[tab]STRING @cText,;
[tab]INTEGER nType

DECLARE INTEGER GetWindow IN Win32API;
[tab]INTEGER hWnd,;
[tab]INTEGER nType

DECLARE INTEGER SendMessage IN Win32API;
[tab]INTEGER hwnd,;
[tab]INTEGER uMsg,;
[tab]INTEGER wParam,;
[tab]INTEGER lParam

#DEFINE WM_CLOSE 0x0010

lcTitle = [Adobe Reader]
hNext = GetActiveWindow() && Current app's window
* Iterate through the open windows
DO WHILE hNext # 0
[tab]cText = REPLICATE(CHR(0),80)
[tab]GetWindowText(hNext,@cText,80) && Get window title
[tab]IF UPPER(ALLTRIM(lcTitle)) $ UPPER(cText)
[tab][tab]* parameter text is present in window title
[tab][tab]SendMessage(hNext,WM_CLOSE,0,0)
[tab][tab]EXIT
[tab]ENDIF
[tab]hNext = GetWindow(hNext,2) && Next window
ENDDO


FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Rather than using SHELLEXECUTE to run Acrobat, couldn't you just print to the Adobe PDF printer driver? That's what I do and it works fine. I print 8-10 reports in a batch, each to a separate PDF file, and then email the reports to two to six users by running Outlook as an automation server. Using REGISTRY.VCX to pre-initialize (yuck - ugly word!) the PDF filename in the registry allows the process to run without user intervention. I do this for up to 20 customers at a time, but the volume is irrelevent.

The process works without a hitch with Acrobat 5. With Acrobat 6, Acrobat is invoked at the end of the print cycle; I haven't figured out how to deal with that yet, so I just stayed with Acrobat 5 on the one computer that runs and emails the reports.

You didn't say, but I suppose that if you're combining multiple VFP reports into a single PDF file this technique might not work.

Mike Krausnick
Dublin, California
 
Because we intersperse text files with PDF files, combining everything in to a single pdf file will not work. What I really need is to be able to determine if Acrobat Reader has printed the selected file before proceeding.

What complicates things more is that we're printing FDF filled PDF files. Using Adobe ActiveX (OLE) would seem to be the way to go. But I don't know how to import the FDF files as FDF files cannot be loaded. Also, how do I print?
 
I've figured out how to print. The command:

ThisForm.Olecontrol1.PrintAll()

works. Now I just need to figure out how to Import the FDF.
 
I tried using the above code to cloe Acrobat and it works most of the time.

In some cases I use =ShellExecuste to print a PDF file. It appears that if the "Close" command is executed before the document is queued, the "Close" command doesn't work. I suspect you cannot close the window if the application is busy.

Any ideas or suggestions.
Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top