Consultor Eletrônico



Kbase P25182: ActiveX: How to open a .pdf file from Progress 4GL using the Windows WinExec API function?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   09/11/2010
Status: Verified

GOAL:

ActiveX: How to open a .pdf file from Progress 4GL using the Windows WinExec API function?

GOAL:

How to use pdf with progress

FACT(s) (Environment):

Windows
OpenEdge Category: Language (4GL/ABL)
Progress 8.x
Progress 9.x
OpenEdge 10.x

FIX:

The 4GL/ABL OS-COMMAND statement has been reported not to open a pdf file when the .pdf file and/or the Acrobat Reader executable have long path names with spaces and when using Acrobat Reader 4.0 and Windows XP. The following solution has been tested successfully under Windows 95, 98, Me, XP SP1 & 2K SP3:

/* beginning of program sample */
DEFINE VARIABLE iReturnResult AS INTEGER NO-UNDO.
DEFINE VARIABLE cProgramName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFileName AS CHARACTER NO-UNDO.

cProgramName = "C:\Program Files\Adobe\Acrobat 5.0\Reader\acrord32.exe".
cFileName = "C:\Program Files\Adobe\Acrobat 5.0\Help\ENU\acrobat.pdf".

PROCEDURE WinExec EXTERNAL "KERNEL32.DLL":
DEFINE INPUT PARAMETER ProgramName AS CHARACTER.
DEFINE INPUT PARAMETER VisualStyle AS LONG.
DEFINE RETURN PARAMETER StatusCode AS LONG.
END PROCEDURE.

RUN WinExec (INPUT cProgramName + CHR(32) + cFileName , INPUT 1, OUTPUT iReturnResult).

IF iReturnResult >= 32 THEN
MESSAGE "Application was Started" VIEW-AS ALERT-BOX.
ELSE
MESSAGE "Application Failed:" iReturnResult VIEW-AS ALERT-BOX.
/* end of program sample */

In Adobe Acroread version 9 it is possible to pass additional command parameters to acrord32.exe.
As an example here is a modification to the variable cProgramName:
cProgramName = "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe /A ~"page=1~"".

For more information on additional parameters you may review this Adobe webpage (this webpage may change so you may need to search for it with the search string "pdf open parameters".
Adobe Parameters for Opening PDF, http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf