Preview with Acrobat

This forum is for eXpress++ general support.
Post Reply
Message
Author
omni
Posts: 554
Joined: Thu Jan 28, 2010 9:34 am

Preview with Acrobat

#1 Post 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

BruceN
Posts: 280
Joined: Thu Jan 28, 2010 7:46 am
Location: Slidell, LA

Re: Preview with Acrobat

#2 Post 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
There are only 10 kinds of people - those who understand binary and those who don't :)

User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

Re: Preview with Acrobat

#3 Post 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
greetings by OHR
Jimmy

User avatar
jdsoft
Posts: 116
Joined: Thu Jan 28, 2010 1:13 pm
Location: Overberg
Contact:

Re: Preview with Acrobat

#4 Post 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
Regards,
Jack Duijf

omni
Posts: 554
Joined: Thu Jan 28, 2010 9:34 am

Re: Preview with Acrobat

#5 Post 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

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Preview with Acrobat

#6 Post 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.
The eXpress train is coming - and it has more cars.

omni
Posts: 554
Joined: Thu Jan 28, 2010 9:34 am

Re: Preview with Acrobat

#7 Post by omni »

Gotcha. I did not see that.

Thanks

Fred

Post Reply