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

HELP! PDF PROBLEMS 1

Status
Not open for further replies.

anyhandle

Programmer
Dec 1, 2000
57
US
I get a report printing using Adobe PDF and seems to work fine. The very next day, I run the very same report and it doesn't work. This was a complaint of my clients as well. I've tried XFRX and quite frankly, I think they still use the Adobe driver. My client wants me to quickly switch between drivers to create a pdf file then immediately after switch drivers and print a FoxPro report.

1) I suspect that the drivers switch very quickly
2) Although running a report and creating a PDF was working one day and not the next hasn't happened in the past, it happened today. What would cause this?

Thanks

Using Acrobat 6.0 on Windows 2000
 
Can you share some code as to how or what you are doing? It's difficult to analyze a "I've got a problem" question. What version and service pack level of VFP are you using? What OSs are having problems?

Rick
 
Anyhandle
XRFX is not PDF printer driver as well as other tools in a market (FRX2Any, eReport, ReportDepot). You might want to try them.

HTH
 
I don't have the adobe printer driver installed, and I can create PDF files with XFRX. What's not working? Is it the creation of the PDF or trying to open an existing PDF?


-BP (Barbara Peisch)
 
I tried making my code more simple, it worked for a while then after about 9 runs of different reports while testing, all of a sudden all reports stopped. I can't even get those that were working to work. I tried cleaning out the temp files and rebooting, but this doesn't seem to be an OS problem. This same series of events happend prior to my changing the code. This was originally Rick Strahl's code which I changed to suit my application.

***************Code
#INCLUDE WCONNECT.H

Set PROCEDURE TO wwPDF ADDITIVE
Set PROCEDURE TO wwEVAL ADDITIVE

*************************************************************
Define CLASS wwPDF50 AS RELATION
*************************************************************
*** Author: Rick Strahl
*** (c) West Wind Technologies, 1999
************************************************************
************************************************************* wwPDF40 :: PrintReport
*********************************
************************************************************Function PrintReport
Lparameters lcReport, lcOutputFile, lcExtraReportClauses, llconsole
Local loEval, ltStart, lnHandle

lcExtraReportClauses=IIF(EMPTY(lcExtraReportClauses),"",lcExtraReportClauses)
This.cErrorMsg = ""

*** Make sure we erase existing file first
Erase (lcOutputFile)

*** Check if we have PDFWriter installed (safely using wweval)
loEval = CREATE("wwEval")
loEval.ExecuteCommand("SET PRINTER TO NAME '" +THIS.cPrinterDriver +"'")
If loEval.lError
Wait window "ERROR: " + loEval.cErrorMessage
This.cErrorMsg = "Couldn't set printer to " + THIS.cPrinterDriver
Return .F.
Endif

*SET PRINTER TO NAME (THIS.cPrinterDriver)

*** We'll create a Postscript Output File
*lcTFile = SYS(2023) + "\" + SYS(2015) + ".ps"
Release pcTFile
Public pcTFile

*pcTFile = SYS(2023) + "\" + SYS(2015) + ".ps"
pcTFile = (ALLTRIM(pchome)+ "\MyFile.ps")
Report FORM (lcReport) &lcExtraReportClauses NOCONSOLE TO FILE &pcTFile
Set PRINTER TO

*** Get rid of the PS file - empty.
*** Distiller will automatically create a PDF file with ps.pdf extension

*** Note: PDFWriter will create two files .ps and .ps.pdf
*** the latter of which contains the actual output data
*If file(pcTFile)
* ERASE (pcTFile)
*Endif
*lcTFile = FORCEEXT(pcTFile,"pdf")

lcTFile = FORCEEXT((ALLTRIM(pchome)+ "\MyFile.ps"),"pdf")
If FILE(lcTFile)
If NOT FILE(lcOutputFile)
Rename (lcTFile) TO (lcOutputFile)
Endif
Else
If FILE(lcTFile)
If NOT FILE(lcOutputFile)
Rename (lcTFile) TO (lcOutputFile)
Endif
Else
&& use for display in pdf
pcadobe="C:\Program Files\Adobe\Acrobat 6.0\Acrobat\Acrobat.exe"

Declare INTEGER ShellExecute IN shell32.dll ;
Integer hndWin, ;
STRING cAction, ;
STRING cFileName, ;
STRING cParams, ;
STRING cDir, ;
INTEGER nShowWin
cAction = "open"
lno=ShellExecute
(0,"open",pcadobe,"MyFile.ps","",1)

Wait WINDOW AT 15,45 timeout 2 "Please save to
Yelpage directory."
Messagebox("Done viewing?")
If FILE((ALLTRIM(pchome)+"MyFile.pdf"))
Copy file (ALLTRIM(pchome)+"MyFile.pdf") TO
(lcOutputFile)
Endif
* This.cErrorMsg = "Output file not created"
* Return .F.
Endif
Endif
If FILE(FULLPATH(JUSTFNAME(lcTFile)))
lcTFile = FULLPATH(JUSTFNAME(lcTFile))
If NOT FILE(lcOutputFile)
Rename (lcTFile) TO (lcOutputFile)
Endif
Else
If FILE(lcTFile)
*** Move the temp file to the actual file name by renaming
If NOT FILE(lcOutputFile)
Rename (lcTFile) TO (lcOutputFile)
Endif
Else
This.cErrorMsg = "Output file not created"
Return .F.
Endif
Endif
Return .T.
Endfunc
* wwPDF :: PrintReport


 
In one of my client's applications I need to "print" a report out to a JPEG file.

To do that I have installed a JPEG Image "Printer". Additionally I need to toggle back-and-forth between the user's typical Default Printer and this Image Printer.

* --- Determine Existing Default Windows Printer ---
lcDefaultPrinter = SET("PRINTER",2)

* --- Use APRINTERS() To Determine What Printers Avail ---
=APRINTERS(gaPrinters)

* --- Use Windows Scripting To Set Windows Default Printer To New Image Printer ---
lcNewPrinter = "Image Printer"
oNET = CREATEOBJECT("WScript.Network")
oNET.SetDefaultPrinter(lcNewPrinter)

* --- Also Set Foxpro Default Printer ---
SET PRINTER TO NAME (lcNewPrinter)

* --- "Print" Report Form To Image File ---
SELECT RptFile
REPORT FORM (MyFRXFile) TO PRINTER NOCONSOLE

* -- Delay Here To Ensure Image File Creation Is Complete ---
< Code To Check If File Size Has Stopped Growing >

* --- When Done Printing - Use Windows Scripting To Restore Original Windows Default Printer ---
oNET.SetDefaultPrinter(lcDefaultPrinter)
RELEASE ONET

* --- Restore Foxpro Default Printer ---
SET PRINTER TO NAME (lcDefaultPrinter)


and the image file is written.

I utilized Mike Gagnon's faq184-4140 to see how to accomplish this using Windows Scripting.

It works well for me and causes no problems.

If I needed to print a PDF file I would use the same approach. There are PDF print drivers out on the Web (many are free) to install on the user's workstation. By following a similar approach you could toggle between the Default Printer and the PDF "printer".

Good Luck,
JRB-Bldr
 
Thanks everyone for your input.

Well, thanks to jrbbldr I found out where the problem is. jrbbldr calls his report differently than I do. He prints to a printer rather than a file and I was able to see that it freezes while printing to the printer. Interestingly enough, sometimes the application flies by this rather than freezing which confused me as to where the problem was.

Apparently my scope line in the report call is too complicated for these drivers to handle. Most of my reports are complex and have very lengthy scope lines such as:

Report Form rankdir Preview For POPPCT#0.00 While (((aaa)<MTOPCNT) And (mtoppct<=99999)) And (aabbcc<=mtoppct)

lcExtraReportClauses ='s "For POPPCT#0.00 While (((aaa)<MTOPCNT) And (mtoppct<=99999)) And (aabbcc<=mtoppct)"

Now what do I do?
 
Rather than limiting the scope in the REPORT command, limit the table that the report uses.

Either use a SQL query to create a limited scope cursor version of your primary table, or use a SET FILTER on the primary table prior to the REPORT command line.

The the REPORT command line will work as usual, but on the more limited set of records.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top