[Jsprintsetup] Problems with setPrinter

Nathan Horter nate at merchantos.com
Fri Feb 12 08:45:18 PST 2010


Hi,

I'm having the same issue that was reported in November:
http://www.mozdev.org/pipermail/jsprintsetup/2009-November/000008.html
I am trying to use setPrinter to change the printer used for printing from
the default printer on the system to another printer. However the default
printer always gets the print jobs.

I'm on Ubuntu running Firefox 3.5.7

I am using essentially the same code that was reported before and I have
made the changes suggested in the response to the email above. With the code
below I get an alert that the printer is found and that getPrinter and
getOption both report the correct printer, however when print is called the
job still goes to the default printer rather than the on e selected with
setPrinter. I don't receive any debug alerts (if I intentionally set the
printer name to an incorrect value I can get an alert that the printer
doesn't exist.

Any help would be appreciated.

jsPrintSetup.setGlobalOption('DEBUG', true);
printer_list = jsPrintSetup.getPrintersList();
printer_array = printer_list.split(',');

for (i = 0; i < printer_array.length; i++)
{
    if (printer_array[i].indexOf('Receipt-Printer') > -1)
    {
        var receipt_printer = printer_array[i];
        alert('found receipt printer: '+receipt_printer);
    }
}

jsPrintSetup.setPrinter(receipt_printer);
jsPrintSetup.setOption('orientation', 0);
jsPrintSetup.setOption('marginTop', 0);
jsPrintSetup.setOption('marginBottom', 0);
jsPrintSetup.setOption('marginLeft', 0);
jsPrintSetup.setOption('marginRight', 0);

alert('getPrinter: '+jsPrintSetup.getPrinter());
alert('getOption: '+jsPrintSetup.getOption('printerName'));
jsPrintSetup.print();

Nathan Horter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mozdev.org/pipermail/jsprintsetup/attachments/20100212/5065ad85/attachment.html>


More information about the Jsprintsetup mailing list