Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unreadable .PS output
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01089112
Message ID:
01094401
Vues:
56
Hi Lisa,

Thanks for all the solution hints; they make most sense. But could you clarify what you meant by class-finding being alien to Windows-users and font-embedding?

If by class finding you meant looking up the computer for the folder containing gs' DLLs and EXEs, I think I got that part ok(as far as I can see), and so's my use of macros for proofing against spaces in folders (see relevant parts of code below...).

On font-embedding however, I don't know what you mean, I haven't coded anything to that effect, could you elaborate? (must the path to gs' FONTS subfolder be included, in my VFP path too?)

Thanks
*!* Excerpts of print2PDF.gsfind() which makes sure GS folder exists and contains the 
*!* required DLL and EXE
liGS = adir(laGSFolders, "C:\gs\*.*","D")
if liGS < 1
	this.cError = "Impossible de trouver GhostScript."
	this.lError = .t.
	return .f.
endif

for x = 1 to alen(laGSFolders,1)
	lcTmp = alltrim(upper(laGSFolders[x,1]))
	if "GS" = LEFT(lcTmp,2) and "D" $ laGSFolders[x,5]
		this.cGSFolder = lcTmp
		exit
	endif
endfor

if empty(this.cGSFolder)
	this.cError = "Impossible de trouver GhostScript."
	this.lError = .t.
	return .f.
endif

this.cGSFolder = "c:\gs\"+alltrim(this.cGSFolder)+"\bin\"

if !empty(this.cGSFolder)
	lcTmp = this.cGSFolder + "gsdll32.dll"  &&Make sure the DLL file can be found
	if !file(lcTmp)
		this.cGSFolder = ""
	endif
endif

if empty(this.cGSFolder)
	this.cError = "Impossible de trouver GhostScript."
	this.lError = .t.
	return .f.
else
	this.lFoundGS = .t.
ENDIF
*!* Excerpts of print2PDF.makeps() which create a temporary file to send the result of
*!* a report to.
if empty(this.cPSFile)
	*** We'll create a Postscript Output File (use VFP temporary path and temp filename)
	=ASleep(500)
	wait window 'Création du fichier...' nowait
	this.cPSFile = this.cTempPath + SUBSTR(sys(2015),2) + '.ps'
endif

&& Adding quotation marks in case the PS file's path contains spaces
lcPSFile = '"'+this.cPSFile+'"'

REPORT FORM (lcReport) NOCONSOLE TO FILE &lcPSFile
*!* Excerpts of print2PDF.makePDF() which calls gsconvert() after making sure GS is 
*!* installed and after having created and "space-proofed" the input and output file 
*!* names

lcOutputFile = '"'+this.cStartFolder+'Listes\' + this.cOutputFile + '.PDF"'
lcPSFile	= '"'+this.cPSFile+'"'
wait window "Conversion du fichier Postscript..." nowait noclear
if !this.GSConvert(lcPSFile, lcOutputFile)
	if empty(this.cError)
		this.cError = "Impossible de convertir "+&lcPSFile+chr(13)+;
			"GSConvert() a rencontré un erreur."
	endif
	this.lError = .t.
	return !this.lError				
endif

if !this.GSConvert(lcPSFile, lcOutputFile)
	if empty(this.cError)
		this.cError = "Impossible de convertir "+&lcPSFile+chr(13)+;
						"GSConvert() a rencontré un erreur."
	endif
	this.lError = .t.
	return !this.lError				
endif

**Get rid of .ps file
if this.lErasePSFile
	if !ADeleteFile(&lcPSFile)
		this.cError = "Impossible d'effacer le fichier: "+&lcPSFile
		this.lError = .t.
		return !this.lError
	endif
endif

if !file(&lcOutputFile)
	this.cError = "Impossible de créer le fichier: "+&lcOutputFile+chr(13)+;
					"Le fichier n'existe pas."
	this.lError = .t.
	return !this.lError				
endif
*!* Excerpts of print2PDF.gsconvert() which converts the PS file created by
*!* makeps() into a PDF, using ghostscript.

lcProg = alltrim(this.cGSFolder) + 'gswin32c.exe'

lcParms = 	' -sDEVICE=pdfwrite'+;
			' -sOutputFile='+tcFileOut+;
			' -r'+this.cPrintResolution+;
			' -dBATCH'+;
			' -dNOPAUSE'+;
			' -q'+;
			' -c 3000000 setvmthreshold .setpdfwrite -f '+;
			 tcFileIn
			
*!*	gs -q -dSAFER -dNOPAUSE -dBATCH -sOutputFile=file.pdf [more options] \
*!*	  -sDEVICE=pdfwrite -c .setpdfwrite -f source1.ps [more files] 
			
lcCmd = lcProg + lcParms

**ShellExecute API declaration
DECLARE INTEGER ShellExecute ;
	IN SHELL32.DLL ;
	INTEGER nWinHandle,;
	STRING cOperation,;   
	STRING cFileName,;
	STRING cParameters,;
	STRING cDirectory,;
	INTEGER nShowWindow

liRetVal = ShellExecute(0, "open", lcProg, lcParms, this.cGSFolder, 2)

**Wait for 10 seconds for the file to be converted.
for x = 1 to 10
	wait window 'En attente du PDF: '+alltrim(&tcFileOut) nowait noclear
	=ASleep(1000)
	if file(&tcFileOut)
		exit
	endif
endfor
Pascal Marier-Dionne
Québec, Canada
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform