首页 > 解决方案 > jquery打印设置每张纸的页数

问题描述

我正在做一个 asp.net 项目。在我当前的页面中,我需要打印一个图像,我使用 jquery 来打印这个,我的代码如下。

 function VoucherSourcetoPrint(source) {
        var width = $("#imgWidth").val();
        var height = $("#imgHeight").val();
        return "<html><head><script>function step1(){\n" +
                "setTimeout('step2()', 10);}\n" +
                "function step2(){window.print();window.close()}" +
                "\n<\/script></head><body onload='step1()'>\n" +
                "<img src='" + source + "' style='width: " + width + "px; height: " + height + "px;' /></body></html>";
    }

    function VoucherPrint(source) {
        source = $('#imgCtrl').attr('src');

        Pagelink = "about:blank";
        var pwa = window.open(Pagelink, "_new");
        pwa.document.open();
        pwa.document.write(VoucherSourcetoPrint(source));
        pwa.document.close();
    }

如您所见,高度和宽度取自文本框。调用 VoucherPrint 函数后,它显示如下打印对话框,

在此处输入图像描述

所以我正在努力实现一些目标,

  1. 使用代码删除页眉和页脚
  2. 使用代码增加打印数量,即每页的图像数量?

有没有办法实现这些?通过 jquery 或 CSS?

标签: jquerycssprinting

解决方案


推荐阅读