Paul Mulroney pmulroney at logicaldevelopments.com.au
Mon Jul 18 01:05:17 UTC 2022

Hi Das,

That's correct - when you print a report using the Omnis PDF device, the remote task method $pdfcomplete() is fired, with those parameters.  You can then choose to, for example, trigger a download or take further action.

The pathname you should be setting up when you go to print the report, and it should be a location to a temporary folder with a unique name. Alternatively there's a way for Omnis to generate the filename for you.

The reason why it's sent as a parameter in $pdfcomplete is because you may have multiple reports queued to print, and you may wish to process each one differently eg email one, but display the other in a remote form, or if printing the report fails for whatever reason (parameter 2 is false) then you need to know which report failed.  In our setup, we only expect one report so we don't do anything with these parameters.

Here's the central routine we call from our remote forms to print a report:

> # - Print the specified report
> # IN: report name, report data, report parameters (first parameter is always report title), subject (optional)
> # Generate report output, save as PDF in temporary memory
> # - Setup the Omnis PDF device settings
> Begin reversible block
>   Set report name [psReportName]
>   # Send to screen generates an error "Command not available when executing a method in an instance belonging to a remote task"
>   #   Send to screen                                                            ## This will change the default device, and revert back later.
>   Calculate $cdevice as kDevOmnisPDF                                            ## Current printer is the built-in Omnis PDF device
> End reversible block
> Calculate vsTitle as mid(psReportName,2)                                        ## strip of the leading 'r'
> Calculate $cdevice as kDevOmnisPDF                                              ## Current printer is the built-in Omnis PDF device
> Do Omnis PDF Device.$settemp(kTrue,5) Returns vsReportID                        ## Temporary file that will hang around for 5 minutes before being deleted automatically
> Do Omnis PDF Device.$setdocinfo($ctask.tvUserObj.$getName(),vsTitle,tvCommunityObj.Name)      ## Author, Title, Subject
> Calculate isPath as con(sys(115),'omnispdf',sys(9),'temp',sys(9),vsReportID)    ## Path to where the file is being created.
> Print report * (plReportData,prReportParams)
> If $ctask.tbInAppWrapper
>   # This doesn't work if the browser is set to block popups.
>   # In the iPad, we can't use the file download object - it generates a "download error".  So use the "showpdf" command instead.
>   Do $cinst.$clientcommand('showpdf',row(vsReportID,60))                        ## Display the PDF, wait 60 seconds
> Else
>   # Remote task will call $pdfcomplete when the print job is finished
>   Calculate $cinst.$objs.reportPane.$visible as kTrue
>   Do $cinst.$clientcommand('assignpdf',row('htmlObject','toolbar=1&view=FitH',vsReportID,30,vsTitle))
> End If
> Quit method 
> # --- History


> On 18 Jul 2022, at 7:17 am, Das Goravani <goravanis at gmail.com> wrote:
>   Alter
> I found this in the docs:
> Completing PDF Printing
> When a PDF report completes, the device sends a message to the task (or remote task) that printed the report. The message is $pdfcomplete, and it takes two arguments:
> 1. The pathname of the output report file.
> 2. A Boolean which is true for success, false if an error occurred generating the PDF via Python.
> My question is how do I capture this.
> Are they talking about putting a method in your remote task named $pdfcomplete and it will be called by the pdf device when one completes with two parameters as named above?
> Because I was wondering how/where you get the pathname of the output file when using the device.
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 

The trouble with bucket seats is that not everybody has the same size bucket.
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