Omnis Studio reports - Print to PDF in Windows (silent mode)

Paul Mulroney pmulroney at logicaldevelopments.com.au
Wed Aug 28 07:39:55 UTC 2024


Hi $all

I know this is an old post, but it's just reared it's ugly head for us again.  Apart from using BrainyData's PDFdevice, is there a way to synchronously print PDFs on Windows?

We have something like this:
- There's a method in the Startup_Task called "$pdfcomplete".  This is called when the PDF has finished being generated.  It has two parameters: report file path and success flag.  We override this method and use this to store an instance var in the Startup_Task to indicate that we're done creating our PDF.
- We use the normal setup to send to PDF and print report eg set print device to be Omnis PDF, set the report path etc, set report name, print report.
- We then open a window that has a timer object in it.  We have an enter data until complete command, and the timer fires every second to test the instance var in the Startup_task to see if it's done.  
- When it's completed, the enter data terminates, the window closes, and execution of the main stack resumes.

Obviously we have some checks eg if it takes too long to generate, or the PDF fails to generate etc, so we don't hang forever.  But it's still a bit lumpy.

Has anyone come up with a better method?  

Regards
Paul.

> On 29 Apr 2020, at 1:19 am, Ben Weinberg <ben at pca.com> wrote:
> 
> Phil:
> 
> I used the following code to check if the file is present after printing to pdf:
> 
> 
>       Repeat
>          Do FileOps.$doesfileexist(cFilePath) Returns iReturnFlag
>          Calculate %i as sleep(100)
>        Until iReturnFlag=kTrue
> 
> Ben Weinberg
> 
>> On Apr 28, 2020, at 2:23 AM, Phil (OmnisList) via omnisdev-en <omnisdev-en at lists.omnis-dev.com> wrote:
>> 
>> Just to comment on this...
>> 
>> The main problem we had with the internal PDF print was that it was printed asynchronously.
>> 
>> As in, when Omnis methods started running again, the PDF is still getting produced in the background, and we had no idea when it was completed, we had to check the filesize was not increasing...
>> 
>> Brainy Datas PDFdevice is fully synchronous, so when control returns to the Omnis methods, the PDF is fully there.
>> 
>> This was an issue for us, as generally the reason we are creating a PDF, is because we are just about to email the report to someone, and we cannot attach the PDF to an email, until it has been completed.
>> 
>> regards
>> Phil Potter
>> Based in Chester in the UK.
>> 
>> On 28/04/2020 10:04, Rocco Ventura [Kunvi] wrote:
>>> Hi Mayada,
>>> 
>>> I use these commands to print on a PDF-file, using only... Omnis Studio 😉
>>> 
>>> 
>>> ________________________________
>>> 
>>> If pForceToPDF
>>> 	# Before setting the report name...
>>> 	Calculate ReportDevicePREV as sys(24)		## I save the previous report-device name
>>> 	Do $cdevice.$assign($devices.PDF)
>>> End if
>>> 
>>> If sys(24)='PDF'
>>> 	Calculate DownDIR as "My local path on the Hard-disk"
>>> 	Calculate FilePDF_OUT as con(DownDIR,$clib().$name,"_", pReportName,'_',jst(#D,'D:y-M-D H-N-S'),'.pdf')
>>> 	Do FileOps.$doesfileexist(FilePDF_OUT) Returns Retc
>>> 	If Retc
>>> 		# DELETE the previous PDF-file
>>> 		Do FileOps.$deletefile(FilePDF_OUT)
>>> 		Do sleep(750)		## much better to wait, usually the CPU is faster than the Hard-disk
>>> 	End If
>>> 	Do $root.$prefs.$reportfile.$assign(FilePDF_OUT)
>>> End If
>>> 
>>> # prepare your printing report
>>> 
>>> Set report name [pReportName]
>>> # and use your commands to print the trigger the report...
>>> 
>>> # After the printing if over...
>>> If pForceToPDF
>>> 	# clean the previous PDF-file...
>>> 	Do $root.$prefs.$reportfile.$assign('')
>>> 	
>>> 	# re-set the previous device-name
>>> 	Do $cdevice.$assign($devices.[ReportDevicePREV])
>>> 
>>> 	# on FilePDF_OUT local-var you have the complete path of the PDF
>>> End if
>>> 
>>> Quit method 1
>>> 
>>> Bye
>>> 
>>> Rocco
>>> 
>>> ______________________________________
>>> Distinti saluti. Best regards.
>>> 
>>> Rocco Dr. Ventura
>>> WMS Analist and Software Developer
>>> 
>>> KUNVI srl - Experiences Holding - www.kunvi.it
>>> Email: r.ventura at kunvi.it - Mobile: +39 348 5186051
>>> 
>>> -----Messaggio originale-----
>>> Da: omnisdev-en <omnisdev-en-bounces at lists.omnis-dev.com> Per conto di malkishtini
>>> Inviato: martedì 28 aprile 2020 01:37
>>> A: 'Doug Easterbrook' <doug at artsman.com>
>>> Cc: 'OmnisDev List - English' <omnisdev-en at lists.omnis-dev.com>
>>> Oggetto: RE: Omnis Studio reports - Print to PDF in Windows (silent mode)
>>> 
>>> Hi Doug,
>>> I thought that will be the answer, but just wanted someone to confirm that it is the right path to go.
>>> 
>>> Thank you so much,
>>> Mayada
>>> 
>>> -----Original Message-----
>>> From: omnisdev-en [mailto:omnisdev-en-bounces at lists.omnis-dev.com] On Behalf Of Doug Easterbrook
>>> Sent: Monday, April 27, 2020 7:15 PM
>>> To: OmnisDev List - English
>>> Subject: Re: Omnis Studio reports - Print to PDF in Windows (silent mode)
>>> 
>>> hi mayada.
>>> 
>>> I just did that this weekend …   using Brainy data’s  print to PDF.
>>> 
>>> 
>>> 
>>> 
>>> Doug Easterbrook
>>> Arts Management Systems Ltd.
>>> mailto:doug at artsman.com
>>> http://www.artsman.com
>>> Phone (403) 650-1978
>>> 
>>>> On April 27, 2020, at 3:56 PM, malkishtini <malkishtini at gmail.com> wrote:
>>>> 
>>>> Hi $all,
>>>> 
>>>> 
>>>> 
>>>> Any advice about the best way to print Omnis studio reports as PDF files saved directly on disk (without prompting the user to make any selection or to enter the file name)? I.e. automate the printing process.
>>>> 
>>>> 
>>>> 
>>>> Thank you,
>>>> 
>>>> Mayada


I took the shell off my racing snail, thinking it would make him run faster. If anything, it made him more sluggish.
-- 
Paul W. Mulroney                                            We Don't Do Simple Pty Ltd 
pmulroney at logicaldevelopments.com.au       Trading as Logical Developments
www.logicaldevelopments.com.au                   ACN 161 009 374 
Ph: +61 8 9458 3889                                       86 Coolgardie Street
                                                                         BENTLEY  WA  6102





More information about the omnisdev-en mailing list