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

API call to print webpage from within VFP 7 2

Status
Not open for further replies.

CMcC

Programmer
Feb 5, 2002
196
US
Hello all.

I have a call to ShellExecute within my VFP 7.0 app that opens a PDF that resides on a website. here is that code:
Code:
DECLARE INTEGER ShellExecute IN shell32.dll ; 
  INTEGER hndWin, ;
  STRING cAction, ;
  STRING cFileName, ;
  STRING cParams, ;
  STRING cDir, ;
  INTEGER nShowWin

cFileName = "[URL unfurl="true"]http://seminoletax.org/Tags/Forms/82040.pdf"[/URL] 
cAction = "open"
ShellExecute(0,cAction,cFileName,"","",1)

This works like a charm and opens up the PDF.

My question is...can I now programatically 'print' this page, ie, call something like javacript.window.print()?


I would like it to automatically print when the pdf opens.

Any and all help is appreciated![pipe]
CMCC
 
Hi Olaf.
Would I need to call another shellexecute after the shellexecute with 'open'? Ie:

Code:
DECLARE INTEGER ShellExecute IN shell32.dll ; 
  INTEGER hndWin, ;
  STRING cAction, ;
  STRING cFileName, ;
  STRING cParams, ;
  STRING cDir, ;
  INTEGER nShowWin

cFileName = "[URL unfurl="true"]http://seminoletax.org/Tags/Forms/82040.pdf"[/URL] 
cAction = "open"
ShellExecute(0,cAction,cFileName,"","",1)

cFileName = "[URL unfurl="true"]http://seminoletax.org/Tags/Forms/82040.pdf"[/URL] 
cAction = "print"
ShellExecute(0,cAction,cFileName,"","",1)

Please let me know...thanks for the fast response.
CmCC
 
Do a google search on:

snagit software techsmith

Snagit is a very inexpensive (free trial version) that does a lot of cool stuff with images. I believe there is a function to capture webpages.

For only a few dollars it could save you a lot of headaches, and you will find yourself using it all the time.

No - I do not work for snagit. Just love the product. Even Rick Strahl has incorporated it into some of his apps.



Jim Osieczonek
Delta Business Group, LLC
 
CMCC,

I don't think "print" will work with ShellExecute() in this case.

However, you could do this:

Code:
owb = CREATEOBJECT("internetexplorer.application")
owb.Navigate2("[URL unfurl="true"]http://www.mywebsite.com/index.htm")[/URL]
owb.ExecWB(6,1)
owb.quit

I haven't tried doing this with a PDF, but you can give it a try.

Note that the above method always displays a Windows Printer dialogue. I know there's a way of avoiding that, but can't put my finger on it just now.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
print" instead of "open" will work in the first call, if the file type is associated with that action. In case of pdf it depends on the PDF reader installed if it works.

But it suerly does not work with a http:// URL.

First download the PDF eg with URLDownloadToFile() and then print the downloaded file with cAction="print" and cFilename="path on hdd".

Bye, Olaf.
 
Thank you Mike and Olaf. I will try this today and let you know. the print dialog is fine, as the users need to select from a list of printers anyhow. thanks again
Cmcc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top