Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
PDF on form
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Photos et traitement d'images
Titre:
Divers
Thread ID:
00664486
Message ID:
00664605
Vues:
25
>If you have the free Acrobat Reader on your machine, you will find an 'Adobe Acrobat Control' ActiveX component (Tools/Options/Controls/ActiveX). Insert it into your form and change it's properties to point to the file you want to view.
>
>You'll need to distribute that dll with your app - or require the Acrobat Reader install at least...
>
>>How can I create a PDF Object on my form to few PDF files.
>>
>>CREATEOBJECT(????????????????)
>>??????????
>>??????????
>>
>>Thanks,
>>Ben

The difficulty with the Adobe Acrobat Control is that it is only guaranteed to work in a web browser. (if you visit the Adobe site that is what they say) I found that on some computers using the Pdf ActiveX control directly on the form a C000005 error or some other error would occur and cause VFP to die ungracefully. My solution was to make a form with a web browser control on it and then to generate a temporary HTML file that only contained the PDF control pointed to show the PDF file. The Resize() event of the form makes the web browser control fill the whole form. I also had to set the HTML file to have no margins so it would appear that the PDF control filled the whole form. This works with Internet Explorer version 5.5 and 6.0, but I do not see why it would not work with version 3.0 and later. I added a property to the form to hold the name of the temporary html file. I cannot think of any other oddities in my code that might confuse you.

Here is my code from the Init() event of the form, the PDF file name and a form caption were expected to be passed in as parameters to the form:
LPARA tcFileName, tcCaption
LOCAL lcStr, lnHandle, lnLength

IF NOT DODEFAULT()
  RETURN .F.
ENDIF

IF VARTYPE(tcFileName) # "C" OR EMPTY(M.tcFileName) ;
    OR NOT FILE(M.tcFileName)
  RETURN .F.
ENDIF

THIS.Resize()

IF VARTYPE(tcCaption) = "C"
  THIS.Caption = M.tcCaption
ELSE
*    THIS.CAPTION = "Acrobat File: " + JUSTFNAME(THIS.OLEACROBAT.SRC)
  THIS.CAPTION = "Acrobat File: " + JUSTFNAME(m.tcFileName)
ENDIF

IF ISFILE(THISFORM.HtmlFile)
  ERASE (THISFORM.HtmlFile)
ENDIF

lcStr = [<OBJECT CLASSID="clsid:CA8A9780-280D-11CF-A24D-444553540000" WIDTH="100%" HEIGHT="100%">]+CHR(13)+CHR(10)
lcStr = lcStr + [<PARAM NAME="SRC" VALUE="]+FULLPATH(m.tcFileName)+[">]+CHR(13)+CHR(10)+;
  [<EMBED SRC="]+FULLPATH(m.tcFileName)+[" HEIGHT="100%" WIDTH="100%">]+CHR(13)+CHR(10)
lcStr = lcStr + [<NOEMBED> <A HREF="]+FULLPATH(m.tcFileName)+;
  [">]+JUSTFNAME(m.tcFileName)+[</A></NOEMBED>]+CHR(13)+CHR(10)+;
  [</EMBED></OBJECT>]+CHR(13)+CHR(10)

lnHandle = FCREATE(THISFORM.HtmlFile)
IF lnHandle = -1
  RETURN .F.
ENDIF
lnLength = FPUTS(lnHandle, [<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">]+CHR(13)+CHR(10)+;
  [<html><head><META http-equiv=Content-Type content="text/html; charset=windows-1252">]+CHR(13)+CHR(10)+;
  [<title>]+thisform.Caption+[</title></head><body scroll="no" leftmargin=0 marginwidth=0 topmargin=0 marginheight=0>]+M.lcStr+[</body></html>])
=FCLOSE(lnHandle)

IF ISFILE(THISFORM.HtmlFile)
  THISFORM.oleWebBrowser.Navigate(THISFORM.HtmlFile)

  lnStartSeconds = SECONDS()
  DO WHILE VARTYPE(THISFORM.oleWebBrowser.Document) # "O" AND (SECONDS()-lnStartSeconds < 15)
  ENDDO

  IF VARTYPE(THISFORM.oleWebBrowser.Document) # "O"
    RETURN .F.
  ENDIF
ELSE
  RETURN .F.
ENDIF

RETURN .T.
I hope this helps,
-Lou.
"All my life I said I wanted to be someone ...
I can see now that I should have been more specific." -Jane Wagner
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform