Click here to Skip to main content
15,880,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a PDF using Itextsharp in my asp.net application and i want to print it directely without downloading.Plz help......
Posted

XML
Hi,
Try this ....call this js function on button click..

function PrintReport()
{
    var strHtml = '<html><head><title>Test Page to print</title></head><body><B>Test Page to print</B></body></html>'//Your Html code here;
    var printContent = strHtml;
    var windowUrl = 'about:blank';
    var uniqueName = new Date();
    var windowName = 'Print' + uniqueName.getTime();
    var printWindow = window.open(windowUrl, windowName);
    printWindow.document.write(
    '<link href="css/style.css" rel="stylesheet" type="text/css" />' +
    strHtml.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "") + '</div>'
    );
    $(printWindow.document).find('a').each(function () {
    $(this).attr("href", "");
    });
    printWindow.focus();
    printWindow.print();
}
 
Share this answer
 
v2
Have a look on this similar QA hope you get some help out:
Print PDF from ASP.Net without preview[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900