Problems with function: setPrefferedPrinter

Hello,

I have a form to print. In need to choose the printer from a table witch have the path because it will change.
We need to print directly, i mean without print preview dialog.
I have the follow code:

controller.setPrefferedPrinter(“Epson LX-300”)
forms.impresion_exms.controller.print(true, false)
if(analisis_to_facturamov_timbre.getSize()>0)
forms.impresion_costo_timbre.controller.print(true, false)
if(analisis_to_facturamov_contado.getSize()>0)
forms.impresion_costo_exm.controller.print(true, false)

But i get the follow error in the setPrefferedPrinter function.

TypeError: Cannot find function setPrefferedPrinter. (C:\Documents and Settings\mcarle\servoy_workspace\PruebaDBF\forms\frm_analisis_gral.js#540)
TypeError: Cannot find function setPrefferedPrinter. (C:\Documents and Settings\mcarle\servoy_workspace\PruebaDBF\forms\frm_analisis_gral.js#540)
at C:\Documents and Settings\mcarle\servoy_workspace\PruebaDBF\forms\frm_analisis_gral.js:540 (impresionInformes)
at C:\Documents and Settings\mcarle\servoy_workspace\PruebaDBF\forms\frm_analisis_gral.js:144 (guardar)

I am working in Servoy 5.1.3 version
Thanks in advantage for your help

mo_ca_mo:
setPrefferedPrinter

your function name contains a typo: ‘setPreferredPrinter’ will do a better job…

mboegem thanks for reply
but i dont undestant what you mean.
Is better use other function? which?

Please look closely at the spelling of ‘Preferred’
1 ‘f’, 2 ‘r’-s not the other way around :-)

Sorry by my silly mistake,
Now is acepting the function setPreferredPrinter:

globals.idFormularioTmp = 1 //(1=timbres) Se setea el tipo de formulario
var array = application.getPrinters()
controller.setPreferredPrinter(array[1])
forms.impresion_costo_timbre.controller.print(true, false)

But is not taking any effect, i mean the form is sent to print but the printer which recive the job is the preffered by windows not the one i wanted.

Are you sure that “Epson LX-300” is the correct name of the printer?

If you want to see a list of all available printers you can do this in Servoy:

application.getPrinters()

Yes i am, even if i put the name manually it doesnt take any effect.

Anyone knows other way to set the printer directly (no with the print dialog).
setPreferredPrinter is not working for me. Always goes to the printer that is the preferred by windows.
Thanks a lot.

My mistake was to put:
controller.setPreferredPrinter(“Epson LX-300”)
instead of:
forms.impresion_costo_timbre.controller.setPreferredPrinter(“Epson LX-300”)
i share this in case it help anyone.
Thank you.

Does this mean that you were calling the method from some other form?

Yes, i think that with the short line i was setting the preferred printer for the form where i writed the line code.
This form was calling to print other form, so i need to write the complete line to really set the preferred printer for this other form

That was not made clear in your original post.