Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automated Save of PDF in Internet Explorer
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01162782
Message ID:
01162883
Views:
25
>Hi all,
>
>Does anyone know how to do an automated save of a PDF which is running inside Internet Explorer (either via Automation or in the WebBrowser Control)? The full version of Acrobat is installed on the client's system...I don't want the end-user to select the PDF file name.
>
>Thanks for your help.

Below is what I am using to print/save a copy of the document displayed in the WebBrowser Control on the form . You may consider it as a draft:
*Form.ButtonPrint.Click
OLECMDID_SAVEAS             =  4
OLECMDID_SAVECOPYAS         =  5 
OLECMDID_PRINT              =  6

OLECMDEXECOPT_PROMPTUSER =1
OLECMDEXECOPT_DONTPROMPTUSER = 2

lcfile="C:\hello.pdf"  && print output file name
ERASE (lcfile)
DO case
case TYPE("ThisForm.oleControl1.Document.GetVersions")="C" and;
				"pdf"$LOWER(ThisForm.oleControl1.Document.GetVersions)
* pdf file displayed
	* OLECMDID_SAVECOPYAS   does not work , the user dialog cannot be skipped, etc
*	ThisForm.oleControl1.Execwb(OLECMDID_SAVECOPYAS ,OLECMDEXECOPT_DONTPROMPTUSER, lcfile)
	ThisForm.oleControl1.Execwb(OLECMDID_SAVEAS ,OLECMDEXECOPT_DONTPROMPTUSER)

	oShell = CreateObject("WScript.Shell")
	lcWindowSaveASTitle="SAVE A COPY"
	ln=SECONDS()
	DO WHILE NOT oShell.AppActivate(lcWindowSaveASTitle) AND SECONDS()-ln<5
		WAIT WINDOW time 1.0 ""
	ENDDO
	if oShell.AppActivate(lcWindowSaveASTitle)
		oShell.SendKeys("%n")
		oShell.SendKeys(lcfile+"{ENTER}")	
		WAIT WINDOW TIMEOUT 1.0 ""
	endif
	oShell=.null.
	IF file(lcfile)
		WAIT WINDOW TIMEOUT 1.0 "File "+lcfile + " has been created."
	endif

CASE  TYPE("ThisForm.oleControl1.Document")="O"
* NOT pdf file displayed

	=APRINTERS(aa)
	llpdfprinter=.f.
	FOR ia=1 TO ALEN(aa,1)
		llpdfprinter= ("pdf"$LOWER(aa[ia,1]))
		IF llpdfprinter
			EXIT
		endif
	ENDFOR
	IF llpdfprinter
		lccurprinter=SET("PRINTER",2)
		oWSHNet = CREATEOBJECT('Wscript.Network')
		oWSHNet.SetDefaultPrinter(aa[ia,1])

		ThisForm.oleControl1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0)
		* it generates User Dialog and with Windows Title depending on the pdf printer
		* if the title is known, then use
*				oShell = CreateObject("WScript.Shell
*				oShell.AppActivate(.... and so on

		
		oWSHNet.SetDefaultPrinter(lccurprinter)
		oWSHNet = .Null.
				
	ELSE
		WAIT WINDOW "PDF Printer not found?!"
	ENDIF
	
ENDCASE
Previous
Reply
Map
View

Click here to load this message in the networking platform