0

I am working on an asp.net project. in my current page, I need to print an image, I used jquery to print this, my code is below.

 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();
    }

As you can see the height and width are taken from textboxes. after calling VoucherPrint function it shows print dialogue as below,

enter image description here

So I am trying to achieve some things,

  1. Remove header and footer using code
  2. increase no of print, ie no of images per page using code?

is there any way to achieve these? through jquery or CSS?

J M
  • 396
  • 6
  • 23
  • You could target this through CSS using the following media query : `@media print { /* All your print styles go here */ }` – Jake Apr 09 '19 at 11:03
  • how to increase printing image number – J M Apr 09 '19 at 11:06
  • https://stackoverflow.com/questions/8228088/remove-header-and-footer-from-window-print[Find trough this](https://stackoverflow.com/questions/8228088/remove-header-and-footer-from-window-print) – Asiri Mahalaksha Apr 09 '19 at 11:06
  • thank you, using CSS the header and footer are hidden but how to print multiple images on a page – J M Apr 09 '19 at 11:23

0 Answers0