print preview code execution

Hello,

I had a method that did this:

someCode
someform.controller.showPrintPreview();
somMoreCode

in RC2 the method seemed to “wait”, until the form showing the preview was closed on way or another. Now in RC3 the code runs directly to the end.

What is expected behaviour in this situation?

Thanks
Patrick

Can any of the servoyans respond to this?

Why the change?
This new behavior is for me a royal pain in the butt. :?

Servoy Developer
Version R2 2.2.1rc-build 330

showPrintPreview has never waited… nothing is changed there

Jan Blok:
showPrintPreview has never waited… nothing is changed there

Indeed, it has always been this way, but I would like to see it changed! :)

I guess I never noticed it because I used it as last function.
But now I need to execute code AFTER the print preview is closed and is conditional if it was printed or not.
So I am having a hard time with this.

Any chance to make it optional to let it wait until the close button is pressed in Print Preview?

Yeah this is troublesome.

how can one print to PDF from preview using the PDFOutput plugin?

How can we know if the user clicked on ‘print’ or ‘close’ from the preview?
This code won’t work because end print job will return byte length 0 before the user even clicks print.

//	start the print job
plugins.pdf_output.startMetaPrintJob();

//	show the preview
controller.showPrintPreview(false, plugins.pdf_output.getPDFPrinter());

//	get the print job
var bytes = plugins.pdf_output.endMetaPrintJob();

Any further word on this?

What trigger can be used to run a method after a print preview is done, ie closed.

We have a form that uses a getImage from a custom bean. We have to show this form for the bean to update.

It is a special form just for printing. We have to show the form, rather than just loadRecords, as the getImage function returns just a black graphic if the bean doesn’t show in servoy when the getImage method is triggered.

Then, a print preview close returns to the badly formatted (print sliding use extensively) print form.

So, is there any trigger for when a print preview is closed? or method to capture / wait real-time within a method?

NCM
FSCI

Hi,

There is an: ```
application.isLastPrintPreviewPrinted()


Have you considered just setting a global variable when you initiate the print preview and then have a condition in the onShow of the form that you end up at that then checks for the global variable and does something based on that - sort of as follows:

'print_preview' method

globals.preview_flag = 1;
forms.print_form.controller.showPrintPreview();


'on_show' method [on badly formatted form]

// other on_show processes followed by
if (globals.preview_flag == 1)
{
// reset the flag
globals.preview_flag = 0
//do something after the print preview !!!
}


Hope this helps

Cheers
Harry