Page 1 of 1
Preview with Acrobat
Posted: Thu May 05, 2011 12:26 pm
by omni
Roger,
We have a user that cannot preview with acrobat. The message states file does not exist. Tested on their server and it works fine. It appears that the server is not thru saving the file before acrobat attempts to open it. Of course, it is faster on the server.
Any way to delay Acrobat that you know of, or delay calling acrobat?
Thanks
Fred
Omni
Re: Preview with Acrobat
Posted: Fri May 06, 2011 6:27 am
by BruceN
this may seem incredibly obvious (or perhaps I don't fully understand the issue),. but why not:
// save file
sleep(100) // (or whatever time period is needed)
//call acrobat
bruce
Re: Preview with Acrobat
Posted: Fri May 06, 2011 3:16 pm
by Auge_Ohr
omni wrote:It appears that the server is not thru saving the file before acrobat attempts to open it.
use FILE() to test before
Code: Select all
DO WHILE !lExit
IF FILE(cFileName )
oPDF:loadFile( cFileName )
EXIT
ENDIF
SLEEP(100)
ENDDO
Re: Preview with Acrobat
Posted: Sun May 08, 2011 5:14 am
by jdsoft
Hello,
Had same poblem before. I assume you create PDF using DCPRINT
Wrote a simple function to fix this.
Code: Select all
cPdfFile := "C:\Data\Documents\Pdf\Invoices_" + StrZero(nInvoice,6) + ".Pdf"
DCPRINT ON NAME SELECTIE_PRINTDEVICE SIZE nMaxLines,100 FONT FONT_NORMAL TO oPrinter TOFILE OUTFILE (cPdfFile) NOSTOP
...
DCPRINT OFF
if WaitForFile(cPdfFile)
ShellExec(cPdfFile)
else
MsgBox("Unable to create PDF file " + cPdfFile)
endif
And now the WaitForFile() Function
Code: Select all
Function WaitForFile(cFileName,nWait)
LOCAL nStop := 0
LOCAL lRet := TRUE // Assume file found
Default nWait to 10 // Default 10 seconds timeout
if !File(cFileName) // File not found
nStop := Seconds() + nWait // Timout moment
if nStop >= 86400 // Over midnight (Extra timeout)
Do while !File(cFileName) .and. ; // File not found
Seconds() >= 86400 - nWait // Wait for midnight
Sleep(1) // Prevent CPU 100% load
Enddo
nStop := Seconds() + nWait // New timeout
endif
Do while !File(cFileName) // As long as file not found
if Seconds() <= nStop // Within timeout periode
Sleep(10) // Prevent CPU 100% load
else // Time-out
Exit // Exit loop
endif
Enddo
lRet := File(cFileName) // Test for file
endif
//
// lRet = TRUE : File found
// = FALSE : File not found within timout periode
//
Return lRet
Regards,
Jack Duijf
Re: Preview with Acrobat
Posted: Mon May 09, 2011 12:52 pm
by omni
I am actually alluding to the dc_printeroff() in _dcprc.prg for dclipx.
There is a sleep(10) under one, and no sleep for the other /else.
Not sure what "IF DC_PrintPreviewAcrobatOpt()[1] == 1" represents.
On the else there is no sleep. The acrobat is called right after the printer is off, and it appears its too fast on some servers.
They are selecting the preview with acrobat from prchoice.prg, with some modifications, but basically the same.
Thanks
Fred Henck
Omni
Re: Preview with Acrobat
Posted: Mon May 09, 2011 1:29 pm
by rdonnay
Fred -
Open up the file c:\exp19\source\dclipx\_dcprc.prg.
Look for the below code:
Code: Select all
nSeconds := Seconds()
DO WHILE !FExists(cPDFName) .AND. Seconds() - nSeconds < 5
Sleep(50)
ENDDO
lStatus := .F.
DC_SpawnUrl(cPDFName)
Change the number 5 to a much larger number (maybe 30).
Rebuild DCLIPX.DLL by running BUILD19_SL1.BAT.
Re: Preview with Acrobat
Posted: Mon May 09, 2011 1:42 pm
by omni
Gotcha. I did not see that.
Thanks
Fred