Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CreatePDF and Windows NT/Windows 2000
Message
 
 
À
22/07/2002 13:40:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Divers
Thread ID:
00681215
Message ID:
00681282
Vues:
16
>Hi Nadya,
>
>Do you have Houston's source code? Look to see if it uses the following method to print the report. I have found that a period at the end of the file name is necessary under W2K, to keep the file name from being of the form pdfTest.txt.pdf.
>
>
set printer to name "Acrobat PDFWriter"
>report form myReport to file "pdfTest." noconsole
>

I use Houston's code. Here is it with my modifications:
*******************************************************************************
*  Description.......: CreatePDF - creates PDF for specified filename
*  Calling Samples...: CreatePDF('c:\temp\temp.pdf')
*  Parameter List....: tcFileName
*  Created by........: Houston Brennan 06/12/2000
*  Modified by.......: Nadya Nosonovsky 01/23/2002 12:35:21 PM
******************************************************************************
lparameters tcFileName
if vartype(m.tcFileName)<>"C" or empty(m.tcFileName)
	tcFileName='c:\windows\temp\tempfile.pdf' && Hardcoded name
else
	tcFileName=forceext(m.tcFileName,"PDF")
endif
if file(m.tcFileName)
	local lnHandle
	lnHandle = fopen(m.tcFileName,12)
	if m.lnHandle > 0 and fclose(m.lnHandle)
		delete file (m.tcFileName)
		flush
	else
		=messagebox('File '+ m.tcFileName+' is opened right now, so it could not be created...',48,'File is opened...')
		return .f.
	endif
endif
set printer to default && restore default settings for the printer first
declare _fpreset in msvcrt20.dll
=_fpreset()
declare integer Sleep in Win32API integer
Sleep(100) && Wait a little

local cPDFDllFile, lcOldSafety, iInitialize, iIsNT, ;
	cPdfWriter, cPort, iInstalled, iDoPrompt, iSetFileName
cPDFDllFile = "c:\Program Files\Adobe\Acrobat 4.0\Macros\Office95\PDFMon.DLL" && or locate this DLL

if not file(m.cPDFDllFile)
	if messagebox("Required Acrobat Writer DLL is not present on your local drive." + ;
			chr(13)+"Do you want to print to default printer?",36,"Error in CreatePDF")=6
		return .t.
	else
		return .f.
	endif
endif

declare integer PDFMonInitialize in (cPDFDllFile)
declare integer PDFMonIsOSNT in (cPDFDllFile)
declare integer IsPDFWriterInstalled in (cPDFDllFile) ;
	string@ cPDFWriterName , ;
	string@ cPort
declare integer PDFMonDoPrompt in (cPDFDllFile) ;
	integer iWhichProgram

declare integer PDFMonSetPrompt in (cPDFDllFile) ;
	integer iWhichProgram , ;
	integer iNewValue

#define SETPROMPTOFF 0
#define SETPROMPTON 1

declare integer PDFMonSetOutputFilename in (cPDFDllFile) ;
	string cFileName
declare integer PDFMonCleanup in (cPDFDllFile)
*PDFMonCleanup()
iInitialize = PDFMonInitialize()
if m.iInitialize=1
*? "Initialize : "
*?? iInitialize

*iIsNT = PDFMonIsOSNT()
*? "Is NT : "
*?? iIsNT
	lcOldSafety=set('safety')
	set safety off && don't want to be prompted
	cPdfWriter = space(100)
	cPort = space(100)
	iInstalled = IsPDFWriterInstalled(@cPdfWriter, @cPort)
	if m.iInstalled=1 && PDF Writer is installed
		set printer to name 'Acrobat PDFWriter'
	endif
*? "Installed "
*?? iInstalled
*? "PDF Writer : "
*?? cPdfWriter
*? "Port : "
*?? cPort
*?
	iDoPrompt = PDFMonDoPrompt(SETPROMPTOFF)
*? iDoPrompt
*cFileName = "c:\Temp\Test.Pdf"
	iSetFileName = PDFMonSetOutputFilename(m.tcFileName)
*? iSetFileName
*!*	tcFileName = ""
*!*	iSetFileName = PDFMonSetOutputFilename(tcFileName)
*!*	? iSetFileName
	PDFMonCleanup()
else
	if messagebox("Adobe Acrobat Write could not be initialized. "+ ;
		chr(13)+"Do you want to print to default printer?",36,"Error in CreatePDF") =7
		return .f. && They don't want to print
	endif	
endif
if m.lcOldSafety='ON'
	set safety on
endif
*? "Finished."
return .t.
As you see, it doesn't use report form command at all, but just does some manipulations with the Adobe to set name to be produced correctly.

I then run command: REPORT FORM myREPORt TO PRINTER. Actually, we have a special application, called Reporter. So I place part of this command in one of the field of the MetaFile. The reporter application executes actual REPORT FORM command. My CreatePDF program I invoke in the InitExpr of the Report (InitExpr field of Reporter metafile). You see now, why the switch is not that simple...


>If this is how CreatePDF does its work, it should be easy for you to fix.
>
>I will test your procedure this afternoon.
>
>>Hi everybody,
>>
>>We were using CreatePDF program successfully for more than 2 years now. Just found, that this program doesn't work on Windows NT/Windows 2000. Instead the file with PRINTER.TXT.PDF name is created in the directory, which has the application, which runs the report.
>>
>>I need to solve the problem quickly and preferably without switching to another way of producing PDF (but if it's needed, we can). May be we have to change something in the Adobe installation itself. Each machine in the office has Adobe Acrobat 4 installed.
>>
>>Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform