為了改善您的使用體驗,本網站正在進行維護,部分功能暫時無法使用。若本站的文件無法解決您的問題,想要向社群發問的話,請到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 發問,我們的社群成員將很快會回覆您的疑問。

搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

Change print settings of browser using javascript

more options

In my PHP website I am using dot-matrix printer to print invoice bills for my costumers and use the roll paper for this. when I print using Javascript, The printer prints the contents of the bill on the paper by skipping the paper out up to A4 paper length (In my Firefox browser default print paper size is A4). But the length of the content of the bill may not be A4 length. It may less or greater than this. So in short, I need to control the paper size of the browser dynamically. The printer should stop the paper ejection on the completion of bill data.

To do this I am using Js Print Setup Add-on and adjusting paper height settings of the browser for each bills through javascript library associated with this add-on. But it is not a perfect solution because in future the add-on my not be supported by firefox. The new Firefox (Firefox Quantum) not support this addon. So I am using an older version.

I need a permanent solution and full control on printer settings of browser (via javascript code) like Printing device, paper size, margins, show or hide print dialog window, ect. And that should work independent of any add-ons.

In my PHP website I am using dot-matrix printer to print invoice bills for my costumers and use the roll paper for this. when I print using Javascript, The printer prints the contents of the bill on the paper by skipping the paper out up to A4 paper length (In my Firefox browser default print paper size is A4). But the length of the content of the bill may not be A4 length. It may less or greater than this. So in short, I need to control the paper size of the browser dynamically. The printer should stop the paper ejection on the completion of bill data. To do this I am using Js Print Setup Add-on and adjusting paper height settings of the browser for each bills through javascript library associated with this add-on. But it is not a perfect solution because in future the add-on my not be supported by firefox. The new Firefox (Firefox Quantum) not support this addon. So I am using an older version. I need a permanent solution and full control on printer settings of browser (via javascript code) like Printing device, paper size, margins, show or hide print dialog window, ect. And that should work independent of any add-ons.

所有回覆 (1)

more options

Don't hold your breath for this to be supported in Firefox: https://github.com/edabg/jsprintsetup/issues/39

There has been some work on CSS related to paged media, but current browser support is limited, in particular, you cannot specify that the paper is A4.

https://developer.mozilla.org/docs/Web/CSS/CSS_Pages

It sounds like for your needs you should distribute your own application, or continue to use Internet Explorer 11 with an ActiveX control.

Or can you generate PDF output?