[Gambas-user] Empty PDF problem - maybe Cairo too slow?

Benoît Minisini gambas at ...1...
Fri Aug 16 13:55:41 CEST 2013


Le 16/08/2013 09:13, Rolf-Werner Eilert a écrit :
> I have been trying around this problem and found a reproduceable behaviour.
>
> To make it short, this is the standard way in my program:
>
> Within SUB Main, I read the mails from the server (contact forms), one
> by one. Each one's data is processed into a pdf (pdf made by Cairo
> class) and a mail text body, then sent to the recipient by e-mail via
> the external script (shelling out).
>
> When the whole thing runs from cron, it will deliver 0 Byte PDFs, but
> the originals on the system are fine (the copies remain in the
> directory). The mailing system does not see any error.
>
> Now is the trick: When I use a ready-made pdf copy and call mail-sending
> SUB with these data directly, it will deliver the PDF correctly. This is
> reproduceable.
>
> So my thought was, it might be that when started from cron, the Gambas
> app runs through so fast that it calls mail sending BEFORE Cairo is
> ready writing the PDF. This would mean Cairo is working on its own. So
> there is a file (you have to give the file name before starting to
> print), but 0 bytes, and that is sent. Only after sending the mail, the
> rest of the data is written and remains in the directory.
>
> How could I check for Cairo to be done with the file before sending the
> mail? Or should I just wait couple of seconds?
>
> Rolf
>

AFAIK, Cairo is synchronous, so when Cairo.End() returns, your PDF file 
should be complete. Show us some code...

-- 
Benoît Minisini




More information about the User mailing list