1

I have generated a QR code using jQuery plugin. The QR code is rendered in a div on my webpage. I tried to print the webpage but the qrcode is not printed in the paper.

My code for jQuery for QR code generation:

 $(document).ready(function () {  
    $('#add1').click(function () {
        $("#table1").remove();
        var string2 = document.getElementById("textinput").value;

        jQuery('#qrcodeTable').qrcode({
            render: "table",
            text: string2
        });
    });
});

In view:

@using (Html.BeginForm())
{  
    @Html.TextBoxFor(m => m.encode, new { id = "textinput", style = display:none;" }
}     

<div id="qrcodeTable">         
</div>

EDIT :
Taking Print from webpage
Print Preview image

The qrcode doesnot gets printed from the webpage. Any suggestions.

Community
  • 1
  • 1
kk1076
  • 1,740
  • 13
  • 45
  • 76
  • 2
    obviously, they want it to print out. – Keith Nicholas Jan 04 '13 at 08:10
  • 2
    Can you change the render to render an image? I'm *guessing* that the "table" render method creates a table with cells and the black cells have a background set. Some browsers won't print backgrounds by default. EDIT: Checked the example and it does use background colour. Remove the "render" option to render to canvas and see if that works. Otherwise you'll need to switch on printing backgrounds. – Bernhard Hofmann Jan 04 '13 at 08:16
  • I can suggest you to generate image of that "#qrcodeTable". see http://stackoverflow.com/questions/839216/create-an-image-of-a-div-in-javascript-gif-png – Anirudha Gupta Jan 04 '13 at 08:25
  • @BernhardHofmann , I tried using canvas. Got a Object doesn't support this property or method error in this line .var ctx = canvas.getContext('2d'); In jQuery plugin – kk1076 Jan 04 '13 at 09:53
  • 1
    @kk1076 If you're using IE and it's for a limited audience, you might be able to have the background printing enabled: Tools>Options>Advanced>Printing>Print background colors and images. Otherwise I fear you'll need a different QR code library; maybe http://d-project.googlecode.com/svn/trunk/misc/qrcode/js/ – Bernhard Hofmann Jan 04 '13 at 10:42

0 Answers0