每张jquery打印设置的页面

时间:2019-04-09 10:59:47

标签: jquery css printing

我正在做一个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函数后,将显示如下打印对话框,

enter image description here

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

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

有什么办法可以实现这些目标?通过jquery或CSS?

0 个答案:

没有答案