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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A quick form to show your PDF files within VFP.

Forms & Screen

A quick form to show your PDF files within VFP.

by  ramani  Posted    (Edited  )
1. If you pass a pdf file name with path as parameters, the form will show the file without a file selection choice. If no parameters snt, the button will be auto displayed to choose a PDF file.
2. Cut and paste the following to a prg.. say..
gsPDF.prg
And RUN it from command window or call it from another prg..
=gsPDF() or =gsPDF("cPdfFileName")
**********************************************************
** Form to display PDF files.
**********************************************************
** Author : Ramani (Subramanian.G)
** FoxAcc Software / Winners Software
** Type : Freeware with reservation to Copyrights
** Warranty : Nothing implied or explicit
**********************************************************
** I used PDF reader ver 6.0.
** Should work with earlier versions also
** If necessary change suitably in the line ...
** ADD OBJECT olecontrol1 AS olecontrol WITH ;
** OLEClass = "PDF.PdfCtrl.5"
**********************************************************
PARAMETERS tFile

PUBLIC oform1

oform1=NEWOBJECT("form1")

IF VARTYPE(cFile) # "U"
oForm1.cmdFile.Visible = .f.
oForm1.cmdExit.Visible = .f.
oForm1.oleControl1.Top = 12
oForm1.oleControl1.LoadFile([&cFile])
ENDIF

oform1.Show
RETURN
**********************************************************
DEFINE CLASS form1 AS form

DoCreate = .T.
Caption = "pdfForm"
Name = "Form1"

ADD OBJECT cmdfile AS commandbutton WITH ;
Top = 12, ;
Left = 12, ;
Height = 27, ;
Width = 144, ;
Caption = "Select File", ;
Name = "cmdFile"

ADD OBJECT cmdexit AS commandbutton WITH ;
Top = 12, ;
Left = 168, ;
Height = 27, ;
Width = 84, ;
Caption = "E\<xit", ;
Name = "cmdExit"

ADD OBJECT olecontrol1 AS olecontrol WITH ;
OLEClass = "PDF.PdfCtrl.5", ;
Top = 48, ;
Left = 12, ;
Height = 192, ;
Width = 348, ;
Name = "Olecontrol1"

PROCEDURE Init
ThisForm.ReSize()
ENDPROC

PROCEDURE Resize
ThisForm.Olecontrol1.Height = ThisForm.Height - 60
ThisForm.Olecontrol1.Width = ThisForm.Width - 24
ThisForm.Olecontrol1.Refresh()
ENDPROC

PROCEDURE cmdfile.Click
LOCAL cFile
cFile = GETFILE([PDF])
IF !EMPTY(cFile)
THISFORM.oleControl1.LoadFile([&cFile])
ENDIF
ENDPROC

PROCEDURE cmdexit.Click
ThisForm.Release()
ENDPROC

ENDDEFINE
**********************************************************
** EOF
**********************************************************
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top