22.03.2011 Home
Hom ome e
View PDF in VFP Form | The Bereznikers Visual F oxpr o
Pages Pag es
SQL
Java
C
Offic e
Windows Search
Visu Vi sual al Fo Foxp xpro ro
View PDF in VFP Form
Tags
code foxpro html
Submitted by Sergey on January 1, 2008 - 21:23
mssql
acrobat
sergey sql tsql vfp vfp8 vfp9 winapi wsh more tags
Recent pos p osts ts
activex
code
foxpro
ie
pdf
sergey
vfp
MS Web Browser control can be use d to display contents of different different type of files files , including including PDF.
Note 1
If PDF is is displayed in the the se parate w indow outs ide of the Web
Browser control, launch Adobe Acrobat/Reader and check 'Display PDF Retrieving VFP runtime DLL name name require d by EXE or DLL
in Brow Brow ser' under Internet in the Preferences. To fix fix the sa me p roblem for othe r file file t ypes (.DOC, (.DOC, .XLS, .XLS, etc.) go to Folde r Option s -> File File Types -> DOC-> Click Advanced bu tton -> Choos e Action: open a nd unche ck
Send email via MS MSN N email account
'Confirm 'Confirm open after dow nload' and check 'Browse 'Browse in same window '.
Send email via Yahoo mail account Remove Structural CDX or Memo flag from a table Deleting pages from PDF file through Acrobat automation GDIPLUS.DLL security updates for VFP 8.0 and VFP 9.0 Powershell - Benchmark Command VFP OLE OLE DB provid er
Note 2
There are other wa ys to view view a PDF:
You can open PDF in the default PDF view view er using code from Opening URL in default Web Browser and putting PDF file name into lcUrl. lcUrl. Alternatively, Alternatively, you can use IE instead o f Web Brows er Control loIE = Createobject("internetexplorer.application") loIE.Visible loIE .Visible = .T. loIE. loIE .Navigate Navigate( ("file://" + lcPdfFileName) ...
How to to de tect 64-bi t OS Retrieve HTML from Clipboard
Note 3
more
Optionally, PDF display can be adjusted by calling calling methods o f
PDF ActiveX ActiveX control control after PDF is loade d as show n in AdjustPdfView AdjustPdfView method poste d se parately after sa mple form. form. More More info on PDF Acti ActiveX veX control can can be found in Interapplication Communication API
Recent comments
Reference from Acrobat 8.1 SDK or Acrobat 9.0 SDK at http://www.adobe.com/devnet/acrobat.html?navID=downloads .
See 4 hours 34 min ago help 4 hours 54 min ago Thanks for sharing the code 1 week 5 days ago Re: Does Does n ot work work if 125% Display zoom active 2 weeks 1 day ago Does not work if 125% Display zoom active 2 weeks 1 day ago good code,tanks! 2 weeks 4 days ago Re: Switching Switching p ages... 4 weeks 5 days ago Switching pages... 4 weeks 5 days ago Re: Copy to clipboard 5 weeks 1 day ago Adobe Reader Methods 5 weeks 1 day ago
Note 4
The code code be low has be en gene rated by Class Brow Brow ser from a
form. form. To To crea te a form (.S (.SCX) CX) use follow ing ste ps 1. Create a form form 2. Add Property cPdfFil cPdfFileName eName to the form and as sign empty string string (=SPACE(0)) (=SPACE(0)) to it. 3. Drop Drop o lecontrol on the form and pick Mic Microsoft rosoft We b Browser. 4. Change its name name to oWB. 5. Create method ShowP df on the form form and copy code code from PROCEDURE PROCEDURE ShowP df there. 6. Drop Drop a comm command butto n on the form and copy code from command command 1.Click 1.Click into its click meth meth od. 7. In VFP8 VFP8 and e arlier put NODEFAULT NODEFAULT into REFRESH REFRESH eve nt to preve nt an error. This This is sa mple code. Add error handling and a djust to your requirements requirements as ne cessary. PUBLIC oform1 =
berezniker.com/…/view-pdf-vfp-form
"
"
1/7
22.03.2011
View PDF in VFP Form | The Bereznikers oForm1.Show() RETURN DEFINE CLASS form1 AS form Autocenter = .T. Height = 520 Width = 741 Caption = "Form1" Name = "Form1" * PDF file name cPdfFileName = "=SPACE(0)" * How long to wait for PDF to load nPdfLoadTimeout = 30 ADD OBJECT txtpdfname AS textbox WITH ; Top = 471, Left = 108, Height = 23, Width = 49 ReadOnly = .T., Name = "txtPdfName" ADD OBJECT command1 AS commandbutton WITH ; Top = 469, Left = 623, Height = 27, Width = 84 Caption = "View PDF", Name = "Command1" ADD OBJECT owb AS olecontrol WITH ; Top = 24, Left = 12, Height = 433, Width = 709 OleClass = "Shell.Explorer.2", Name = "oWB" ADD OBJECT label1 AS label WITH ; Height = 17, Left = 36, Top = 474, Width = 63, Caption = "PDF Name", Name = "Label1" PROCEDURE Refresh * Required in VFP8 and earlier to prevent an NODEFAULT ENDPROC PROCEDURE ShowPdf LOCAL lnSeconds * Clear Web browser control by loading blank Thisform.oWB.OBJECT.Navigate2("About:Blank") * Wait for load to complete lnSeconds = SECONDS() DO WHILE (Thisform.oWB.OBJECT.Busy OR Thisfor AND (SECONDS() - lnSeconds) < DOEVENTS ENDDO * Load PDF WAIT WINDOW NOWAIT "Loading PDF ..." Thisform.oWB.OBJECT.Navigate2(Thisform.cPdfFil * Wait for PDF to load lnSeconds = SECONDS() DO WHILE (Thisform.oWB.OBJECT.Busy OR Thisfor AND (SECONDS() - lnSeconds) < DOEVENTS ENDDO WAIT CLEAR * PDF display can be adjusted as shown in Adj * Uncomment next line if you want to do that *This.AdjustPdfView() ENDPROC PROCEDURE command1.Click * Get PDF file name Thisform.cPdfFileName = GETFILE("pdf") * Display the name in the textbox Thisform.txtPdfName.Value = Thisform.cPdfFile IF NOT EMPTY(Thisform.cPdfFileName) * Display PDF
berezniker.com/…/view-pdf-vfp-form
2/7
22.03.2011
View PDF in VFP Form | The Bereznikers
s orm.
ow
ENDIF ENDPROC ENDDEFINE
PROCEDURE AdjustPdfView * PDF control PEMs can only be accessed after * TRY...ENDTRY will prevent crash in case wh TRY loDoc = Thisform.oWB.oBJECT.Document WITH loDoc * PageMode: * none — does not displa * bookmarks — displays t * thumbs — displays the .setPageMode("none") * LayoutMode: * DontCare — use the cu * SinglePage — use singl * OneColumn — use one-c * TwoColumnLeft — use t * TwoColumnRight — use t .setLayoutMode("OneColumn") * ViewMode: * Fit — Fits the entire * FitH — Fits the entir .setView("FitH") * Zoom %, overrides ViewMode a .setZoom(50) * Toolbar On/Off .setShowToolbar(.F.) * Scrollbars On/Off .setShowScrollbars(.T.) ENDWITH CATCH TO oErr FINALLY loDoc = null ENDTRY ENDPROC
Average: Your rating: None Average: 3.2 (10 votes)
Sergey's blog
Add new comment
17496 reads
Where is the location of the documentation ? Submitted by Laurie S (not verified) on June 10, 2008 - 20:26.
Whe re is the location of the actual documentation for the methods you're us ing in AdjustPdfView for setting Pa geMode , LayoutMode , etc.? I'm having trouble ge tting this to w ork... settings see m to be ignored for PageMode. reply
Permalink
Interapplication Communication API Reference from Adobe Submitted by Sergey on June 10, 2008 - 22:02.
berezniker.com/…/view-pdf-vfp-form
3/7
22.03.2011
View PDF in VFP Form | The Bereznikers Laurie, See Note 3 above the code. reply
Permalink
Sure 'nuf Submitted by Laurie S (not verified) on June 11, 2008 - 14:38.
Yes, there it is. Thanks for this post, btw, it is most helpful! reply
Permalink
Adobe Reader Methods Submitted by Anonymous (not verified) on February 13, 2011 14:38.
Laure, Whe re did you find you find the Methods to call. I am looking to se lect all text on a pd f and copy it to clipboard so that I can extact the text I need . Thanks, Bill reply
Permalink
Congratulations very intersting information Submitted by Ignacio Gutierrez Torrero (not verified) on September 3, 2010 - 14:25.
Congratulations, it is a s ite w ith many high qua lity articles o n VFP ! reply
Permalink
ole control owb Submitted by TnT (not verified) on November 22, 2010 - 07:57.
Thanks for the article. I am just wonde ring what else ha ve to be pre -installed on the computer running this code ab ove. I mean: if it is an XP, Vista, 7 doe s it nee d Acrobat Reader to be installed in orde r to wo rk? If it is clean o perating syste m, not having any Adobe stuff, do I nee d to copy, or register so mething, somew here in order to work? Thank you very much for your response! reply
Permalink
Yes it requires Acrobat PDF Submitted by Sergey on November 22, 2010 - 08:03.
Yes it requires Acrobat PDF ActiveX control to be installed on PC. It's a part o f Acrobat Reader or Acrobat installation. reply
berezniker.com/…/view-pdf-vfp-form
Permalink
4/7
22.03.2011
View PDF in VFP Form | The Bereznikers
RE - html Submitted by TnT (not verified) on November 22, 2010 - 18:41.
And...in the case that in the procedure sh owp df() I "Navigat e2" an .html file for e xample ( not to a .pdf file ), I will not nee d to registe r any .dll -s, because W indows has all the necessary stuff for html viewing...Is that right? My program will be use d by users, so I just wa nted to be sure that the y will not have a ny problems at installation and running the .exe, in fact I dont wa nt any further ocx or dll registrations in Window s in order to w ork. (these registrations might be "complex" operations for them...) THNX! reply
Permalink
The Web Browser control is Submitted by Sergey on November 23, 2010 - 14:09.
The Web Browser control is part of IE. IOW, it'll be available as long as you have IE installed o n PC. It can display HTML and s ome othe r file types natively but for the res t you'll have to install appropriate plugins. reply
Permalink
OLE error code 0x80004005: unspecified error Submitted by muklis (not verified) on December 31, 2010 - 03:37.
whe n I run this, the mess age appe ar :(OLE error code 0x80004005: unspecified e rror). I cant solve this. wha t happe nd ?? and how to solve it..?? thanks Iam use Vfp 7 reply
Permalink
Re: OLE error code 0x80004005: unspecified error Submitted by Sergey on January 1, 2011 - 21:06.
I would first make s ure that P DF files can be view ed in Internet Explorer reply
Permalink
I had tried with NOTE2 above, Submitted by muklis (not verified) on January 2, 2011 - 22:59.
I had tried w ith NOTE2 abo ve, and pdf w as a ppea r in IE (Run no trouble), I also ha d trid in Vfp9 and run no t rouble too, actually I want to run your this sample in Vfp7 ( I see code TRY..ENDTRY in in Vfp isn't a vailable), the messa ge 'OLE e rror code 0x80004005: unspecified e rror' is a ppea r every I run the form , if I pus h Ignore command b utton , this sample is
berezniker.com/…/view-pdf-vfp-form
5/7
22.03.2011
View PDF in VFP Form | The Bereznikers Run, but this error annoy. [I have't wa nted move to Newe st Vfp like Vfp9]. I have jus t remove mozila firefox and chan ge d with IE Thanks so much sergey, I wait you respo nse for solve this. thanks reply
Permalink
It looks like you didn't put Submitted by Sergey on January 3, 2011 - 05:48.
It looks like you didn't put NODEFAULT in the Refresh method. reply
Permalink
PDF suddenly in separate Adobe window (not inside form) Submitted by Ginny (not verified) on February 3, 2011 - 10:04.
Hi, i have bee n using this code for about 6 months now and it's bee n wo rking great (thank you!). Howe ver, in the last w ee k or so, sudde nly the PDF opens up in it's own Adobe W indow rather than inside the VFP9 form it was originally displaying in. The reason I like it inside the form is because it forces the user to exit (I put an Exit button o n the form to release it). Suddenly it open s the PDF in a sepa rate Adobe Acrobat w indow, and ope ns the blank form behind Adobe. In order to e xit, I have to exit out o f Adobe, then hit the Exit button o f the form (which is blank because the P DF didn't load inside it). Any idea why this would sudd enly happen? No code ha s bee n changed. Thanks! reply
Permalink
Re: PDF suddenly in separate Adobe window (not inside form) Submitted by Sergey on February 3, 2011 - 10:23.
Hi Ginny, See Note 1 in the a rticle reply
Permalink
Adobe Reader Methods Submitted by Bill (not verified) on February 13, 2011 - 14:45.
Sergey, This is great , I am trying to se lect text from PDF and copy to clipboard for further processing. I am new to OLE Automation an d having trouble finding Methods to call. I've tried note 3 and loo ked through the api documentation but did not see w hat I needed o r even the navigate2 Method tha t you used . Any help with selecting all the text on pdf and copying to clipboard would be great. Thanks, Bill
berezniker.com/…/view-pdf-vfp-form
6/7
22.03.2011
View PDF in VFP Form | The Bereznikers reply
Permalink
Re: Copy to clipboard Submitted by Sergey on February 14, 2011 - 06:48.
Hi Bill, You can use Acrobat Reade r toolbar to se lect and copy text to clipboard. reply
berezniker.com/…/view-pdf-vfp-form
Permalink
7/7