求用JS設置打印參數代碼
我想实现使用默认的打印机,纸张使用A4,横向及设置页边距,取消页眉和页脚等打印参数设置来打印网页内容的JS代码,谢谢!我在网站上找到以下的代码,但使用时出现“factory”未定义错误
<script defer>
function SetPrintSettings() {
// -- advanced features
factory.printing.SetMarginMeasure(2) // measure margins in inches
factory.SetPageRange(false, 1, 3) // need pages from 1 to 3
factory.printing.printer = "HP DeskJet 870C" //打印机选择
factory.printing.copies = 2 //打印份数
factory.printing.collate = true
factory.printing.paperSize = "A4" //纸张设置
factory.printing.paperSource = "Manual feed"
// -- basic features
factory.printing.header = "This is MeadCo" //页眉设置
factory.printing.footer = "Advanced Printing by ScriptX" //页脚设置
factory.printing.portrait = false
factory.printing.leftMargin = 1.0 //左边距
factory.printing.topMargin = 1.0 //上边距
factory.printing.rightMargin = 1.0 //右边距
factory.printing.bottomMargin = 1.0 //下边距
}