为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

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?