pdf generation takes time
Nick Renders
omnis1 at arcict.com
Mon May 5 07:23:31 UTC 2025
Hi Geert,
In our fat client, we read the PDF file in a loop. If the binary is the same size as before, the printing is done.
Calculate i as #CT
Calculate lBinary as #NULL
Repeat
Calculate lBinary2 as lBinary
If rFileOps.$doesFileExist(lFilePath)
Do rFileOps.$readFile(lFilePath,kTrue) Returns lBinary
End If
Until #CT>i+600|(binlength(lBinary)>0&binlength(lBinary)=binlength(lBinary2)) ## 10 seconds
Nick Renders
On 4 May 2025, at 16:46, Geert wrote:
> Hello,
>
> I'm generating a product sheet from a js form by requesting several data in an object from a REST api (pictures, text, url's, picture for every possible colour up to 20,...)
> Using a report class printing to O$11 PDF device (Windows 11)
> After the (4MB to 10MB) file is generated (it takes a few seconds) I show the pdf in another tab page in the browser. (or in the future maybe return a REST response or upload the file to an assets library).
>
> The problem : things go too fast in Omnis Studio. The pdf file is not yet created or still open when I want to show the pdf.
> This can be monitored when issuing Do $devices.PDF.$setparam(kDevOmnisPDFParamKeepScriptAndPNGs,kTrue)
>
> The reason : the PDF file is created by Node.js (which is built-in into Omnis). Omnis generates the .js file plus the PNGs and Node.js executes the .js file to generate the PDF. So Omnis code continues while node.js is still writing to the pdf file.
>
> The possible solution : adding a loop to wait a second, use FileOps to test existence and after that use oFileOps to test if not open anymore. This does not seem to work. I still get an error message in the browser that the pdf file couldn't show. Retrying a few times the pdf is shown anyway but that's not user friendly.
>
> Do you guys have another workaround to know when node.js is really finished ?
>
> Kind regards,
> Geert
>
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
More information about the omnisdev-en
mailing list