Page 1 of 1

printing to pdf error

Posted: Tue Dec 03, 2024 11:34 am
by omni
Roger,

One of our hourly runs for a client creates pdf's for drivers to pick up their pay preview for the week so far. Been running it all year. The employees can also open the pdfs by driver. Not an issue, but have one problem. (Note:drivers can get files on their phone app)

As these are being created (using bullzip and the same name each time for the current pay period) the pdf may be open by the driver or employee and a message comes up to cancel or retry. Found it testing, but it runs on task scheduler so no human can answer and neither would allow to skip that driver and just go to the next one, which is what we would do if we could.
Very rare for this to happen, but it did today, which was unexpected.

Any ideas on how to get by the error, or check the pdf for being open or not. (guess we could try to delete it and if still there, bypass?)

Thanks

Fred
Omni

Re: printing to pdf error

Posted: Tue Dec 03, 2024 5:43 pm
by rdonnay
Fred -

I read your complaint 5 times and I have no idea what error you are getting.
Please be more specific.

Roger

Re: printing to pdf error

Posted: Wed Dec 04, 2024 1:09 am
by Tom
I understand that sometimes those PDF files can't be opened. You have to investigate those files, Fred. Maybe they were damaged during transport or there weren't created successfully. There are lots of possible reasons.

Re: printing to pdf error

Posted: Wed Dec 04, 2024 6:52 am
by rdonnay
I don't know how you are giving the PDF file to the driver.
Is this an email attachment?

Sometimes a server can be slow at emptying its file-write buffer if it is very busy.
If you have another service that sends it out as an email immediately after the print job, it could be that there needs to be a few second delay in that process.

Re: printing to pdf error

Posted: Wed Dec 04, 2024 12:54 pm
by omni
From windows. "file is open and cannot be created" when it tries to write the pdf. Then a retry or cancel

Re: printing to pdf error

Posted: Wed Dec 04, 2024 1:53 pm
by Wolfgang Ciriack
You can try to open the pdf exclusive, f.e.

Code: Select all

do while (nH := FOpen(outfile, FO_EXCLUSIVE)) <= 0 .and. counter < 10
   sleep(100)
   counter++
enddo
if nH > 0
    FClose(nH)
endif
if counter > 10
    err := 1
endif

Re: printing to pdf error

Posted: Wed Dec 04, 2024 5:07 pm
by rdonnay
"file is open and cannot be created"
It appears that you are using the same name for the PDF each time it is being created and a previous print job never finished and closed the file.

Re: printing to pdf error

Posted: Thu Dec 05, 2024 8:42 am
by omni
Guess a lot of confusion. The files are created hourly for the weeks pay and copied to the same place, same file name for each driver id. The drivers have an app on their phone where they can open and view the files via a 3rd party. The files are something like 'payweek_40'. The app requires the same file name due to the app showing the driver the available weeks to view, like this week and next week,etc. They know the week numbers. So the driver may be viewing the pdf. (its on our server at the client site).
The clients employees can also view and open the files.
Yes, we preferred to have different file names for obvious reasons, but would not work with the 3rd party in order for them to show only a specific file name on the driver logins.
Thought that maybe trying to delete the file prior to saving the new one, then checking to see if it still existed, but it caused it to be worse. Get a similar error when deleting using xbase, although we may be able to try deleting using a RUN command, then if its still there it would just go to the next driver.
Not a big deal right now as it does not happen very often, just looking for best method.

Thanks

Fred

Re: printing to pdf error

Posted: Thu Dec 05, 2024 10:04 am
by skiman
Hi,

Deleting the PDF when it is open won't work. I just tried in Explorer and even a rename isn't possible when the PDF is open.

Seems to me that the only solution is to check if it is open and if so don't create the new file. In the next cycle after an hour try it again. Or create the files with another name. Put this in some queue a try it after some time if you can replace the old file with the new one.