Print form with preferred Printer in Web Client

Hi

I am trying to print a form in Servoy Web client. Seems like none of the things are working for me.

  1. Trying to show the Print dialog, to select some printer. But the print dialog to select the printer is never shown.
controller.print(false, true);
  1. How to script to use a preferred printer without showing the Print dialog?
controller.setPreferredPrinter('Samsung ML-2850 Series PCL6');
controller.print(false, false);

This shows the file save dialog to save the form in pdf.

  1. Changing this client property has no impact. Never ever the printer selection dialog pops up.
application.putClientProperty(APP_UI_PROPERTY.USE_SYSTEM_PRINT_DIALOG, true);

Is there some thing which is missing? Please help.

You can’t control the printer, or print dialog, or default printer from a Servoy webclient. (or any website or other webclient, what so ever)

If you use controller.print function inside a webclient, you should be getting a pdf, by default!

Thanks Harjo for the clarification.

Like in javascript, window.print() opens the print dialog, to print the current html page. There should be some way to print from web client.

If you have any workaround, please share.

pradiptab:
Like in javascript, window.print() opens the print dialog, to print the current html page. There should be some way to print from web client.
If you have any workaround, please share.

Indeed, that’s the only thing you can do in a browser, to print the content of the html you see.
The only thing your in control of inside Servoy, is printing to pdf, and serve that as a file, to the browser-client.

There is no workaround…

Harjo:
There is no workaround…

Well, no “easy” workaround … 8)

[attachment=0]screen-print-preview.png[/attachment]

The trick is to roll pdf.js into web client and pass it a pdf (as byte array). You can’t specify a printer via code but the user does get the system print dialog.

Data Sutra has all this built in. API here: http://community.data-sutra.com/project … PI#DSprint. Note helper methods for getting PDFByteArray’s from Servoy form, html, url, file system resource, and media location resource.

Relevant repo starting location: http://community.data-sutra.com/project … S/wc/ds/js

Thats no workaround. Just implementing your own pdf viewer :-)

Harjo:
Thats no workaround. Just implementing your own pdf viewer :-)

Workaround, hack, lobotomize and replace, wire in someone else’s stuff — as long as we don’t have to build it from scratch!

With Servoy 8 this should still be a solid approach to previewing and printing.

Thanks David for the nice suggestion. Will check the pdf.js API for the viewer.