edabg / jsprintsetup

JSPrintSetup Firefox addon
Mozilla Public License 2.0
76 stars 39 forks source link

Cannot define paper size, Firefox ESR 52.4.0 (Raspbian Stretch ) jsPrint Setup 0.9.5.5 #54

Open WWMD3 opened 6 years ago

WWMD3 commented 6 years ago

I am trying to set up a receipt printer on my computer that is 58mm x 210mm. I have gotten it to work just fine with Firefox ESR 52.4.0 on Ubuntu 16.04 and CentOS 7 with the following paper size definition:

jsPrintSetup.definePaperSize(100, 100, 'receipt', 'receipt 58x210', 'Receipt Paper', 58, 210, jsPrintSetup.kPaperSizeMillimeters);

jsPrintSetup.setPaperSizeData(100);

This works well on Ubuntu 16.04 and CentOS 7 (Firefox ESR 52.4.0 32 and 64 bit) and returns: {"PD":100,"PN":"receipt","PWG":"receipt 58x210","Name":"Receipt Paper","W":58,"H":210,"M":1}

Under Raspbian Stretch and Firefox ESR 52.4.0 32 bit I get the following: {"PD":100,"PN":"receipt","PWG":"receipt 58x210","Name":"Receipt Paper","W":5e-324,"H":1,"M":-4096}

Any help resolving this issue would be appreciated.

PS: When reloading the same page, the W and H values set themselves arbitrarily sometimes.

WWMD3 commented 6 years ago

I created a workaround for this, not the most elegant, but I was able to get my pet project back on track.

For anyone interested, I opened up the .xpi file, and edited /components/jsPrintSetup.js and created a line at the end of the paperSizeList{} definition with the papersize I wanted.

mitkola commented 6 years ago

You do not need to modify xpi. The proper way is to use jsPrintSetup.definePaperSize.

WWMD3 commented 6 years ago

Thank you for the quick reply. I used the same exact jsPrintSetup.definePaperSize on both OSes, this is part of the webpage served up. On x86 architectures, the result is predictable and I get a paper size of 58mm x 210mm as expected. When the same call is used on ARM architecture however, the identical call to jsPrintSetup.definePaperSize creates unusual values for W H M that seem to be arbitrarily set, various reloads of the page, create different values returned for W H M (last 3 arguments). They are incredibly small values for W and H and M is a negative integer less than -4000.