Web Connection includes support for various PDF converters including the free GhostScript driver that is essentially a PostScript to PDF converter. It's been in Web Connection and West Wind Internet and Client Tools for a long time and it's been working well for years.
However recently I upgraded my machine to the 64 bit version of Windows and first off I noticed that Ghostscript PDF conversion was no longer working. The first problem - duh - was that I forgot to install Ghostscript, so I headed over to the Ghostscript site and downloaded the most recent version. But alas, I downloaded the 64 bit version and installed that. I also installed a Windows 7 PostScript Printer, the recommended Xerox Phaser 6120 PS printer, which is the defaut choice that wwGhostScript looks for.
But to my display it still didn't work and I continued to get the dreaded error: PDF File not generated. Drat!
Problem #1: 32 bit Registry Keys missing
The problem is that installing the 64 bit version of Ghostscript doesn't work for a number of reasons. The first is that wwIPStuff.dll - which acts as the front end to the Ghostscript native C DLL - looks in the registry for Ghostscript's install path at HKEY_LOCAL_MACHINE\SOFTWARE\GPL Ghostscript. FoxPro being a 32 bit application however causes Windows to re-route HKEY_LOCAL_MACHINE to a different registry path which actually comes out to: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\GPL Ghostscript, which of course doesn't work because the 64 bit version doesn't put any keys there. Thus the first problem is that the registry key is not found.
That can be bypassed by directly providing the wwGHostScript class with the wwGhostScript::cGhostScriptDllPath property which I did explicitly set in code:
oPDF.cPrinterDriver = FindPostScriptPrinter("Xerox Phaser 6120 PS")
oPdf.cGhostScriptDllPath = "C:\Program Files\gs\gs9.04\bin\gsdll64.dll"
*** Temporary filename
lcFile = SYS(2015) + ".pdf"
*** Print the report to a temporay Web Directory
IF !oPDF.PrintReport("custlist.frx",Server.oConfig.owwDemo.cHTMLPagePath + "temp\"+lcFile)
THIS.StandardPage("Report failed to print",oPDF.cErrorMsg)
But it still didn't work.
Problem #2: 64 bit DLLs can't be called by 32 bit Visual FoxPro
And it doesn't work because I missed the obvious: Visual FoxPro is a 32 bit application and a 32 bit application can't call a 64 bit DLL directly.
Aha! The trick to make Ghostscript run on this 64 bit machine was to install the 32 bit version of Ghostscript on the machine. Installing the 32 bit version fixes both of the problems above. It writes the registry entry in the 32 bit SOFTWARE hive where wwIPStuff.dll can automatically find the version and it loads the 32 bit version of the DLL.
It appears that GhostScript 32 bit and 64 bit can coexist on the same machine so if you have another 64 bit application that needs to access the GhostScript dlls it will get the 64 bit version, while 32 bit apps can continue to use the 32 bit version.
Moral of the story: Always remember that FoxPro is a 32 bit application and can't call 64 bit DLLs directly. If you need to interface with third party DLLs that have both 64 bit and 32 bit APIs make sure you always install the 32 bit version or use the 32 bit DLLs if they are available. 64 bit DLLS just don't work.