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

Selecting PDF output seems to change VFP default directory

Status
Not open for further replies.

Mike Lewis

Programmer
Jan 10, 2003
17,512
Scotland

Just came across a worrying bug/feature. Imagine this scenario:

1. Your application sets its default directory to (say) c:\MyApp.

2. The app displays a printer dialogue box (e.g. via SET PRINTER TO NAME or REPORT FORM ... PROMPT).

3. The user uses the dialogue to select a PDF printer driver.

4. The PDF printer driver shows a File Save dialogue for its output file.

5. The user uses that dialogue to navigate to a different directory (say, c:\MyPDFs).

This will cause the VFP default directory to change to the one specified in the Save As dialogue. This in turn will inevitably cause problems further down the road.

I have verified this on my own system, which has the Docucom PDF driver installed. This consistently shows the behaviour described above.

Has anyone else come across this? Does it happen with other drivers?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Oh yeah, we've definitely encountered this. You need to reset your directory after calling the report like so:

LOCAL lcCurrentDirectory
*% Save Current Directory
lcCurrentDirectory = sys(5) + sys(2003)
REPORT FORM foo PREVIEW TO PRINTER PROMPT
SET DEFAULT TO &lcCurrentDirectory

Hopefully you've got you're report calls in an abstract class, otherwise, you need to find all your report calls and add this code to all of them.

Anybody else know a KB article, wiki topic, or FAQ that talks about this? If not, maybe we should create one.

Hope this helps,
Randy
 
Randy, are you using the Docucom PDF driver or some other one? FWIW I use the Amyuni PDF driver and have never seen this problem.

-Rick
 
Rick,
I've seen this with Adobe PDF drivers, Win2PDF, PDf995, etc. There are some other print driver things that will cause the directory to change as well (output to text file, etc.). I think with the Amyuni, the rendering takes place before it writes the file out so you don't have this problem. Also, not sure if this still affects VFP 9 if you're using the new REPORTBEHAVIOR 90.
 

I'm glad to see it's not just me. I hadn't realised it was well-known feature.

Randy, you wrote: Hopefully you've got you're report calls in an abstract class.

Oh, how I wish. That's true (up to a point) in my present application, but I've worked on over a dozen VFP projects over the years; some use my classes, some use the clients', and some don't use any at all. Seems to me that any of these could be vulnerable to this behaviour. I've got no control over which printer drivers the users install.

I'll see if REPORTBEHAVIOR 90 has any effect.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Randy,

I've seen this with Adobe PDF drivers, Win2PDF, PDf995, etc.

Thanks for the heads up, I've got a client right now who's interested in PDF995. In their app I automatically set the output PDF file name and path for them, but so far it's always been to the current VFP directory. I'll have to experiment and see what happens if I send the output to some other directory.

-Rick
 

Just for the record, SET REPORTBEHAVIOR 90 doesn't make any difference.

Come to think of it, there's no reason why it should. The behaviour isn't directly related to reports, after all.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top