Click here to Skip to main content
14,605,691 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello Sir,
I have a billing printer & i have made an aspx page with the help of visual studio 2010 and sql server 2008.page has some textboxes and some labels and one print button.


i just want to print that aspx page... i dont want that print setup or print dialouge box ...is it possible in webform ?? please help me out..i'm in big trouble if possible then please give me the source code of button click..please


Thank you......
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 1

Hello Vivek,

Could you please see the following link:
Printing Using C# - Changing the Page Settings[^]

I have taken following code from it.
Printing Without the Preview

To print to another printer, you have to use the standard print dialog. We can bring this up in much the same way, so add this method to PrintEngine:
// ShowPrintDialog - display the print dialog...
public void ShowPrintDialog()
{
  // create and show...
  PrintDialog dialog = new PrintDialog();
  dialog.PrinterSettings = PrinterSettings;
  dialog.Document = this;
  if(dialog.ShowDialog() == DialogResult.OK)
  {
    // save the changes...
    PrinterSettings = dialog.PrinterSettings;

    // do the printing...
    Print();
  }
}

Again, if the user clicks OK we save the settings, but this time we also call Print to print directly to the configured printer. Add this event handler to Form1 to finish this off:
private void cmdPrint_Click(object sender, System.EventArgs e)
{
  // print...
  _engine.ShowPrintDialog();
}
   
Comments
Suvabrata Roy 11-Jun-14 2:38am
   
Vivek: was asking for his web form but your solution will work in desktop.
Rate this:
Please Sign up or sign in to vote.

Solution 2

For Mozilla : http://forums.mozillazine.org/viewtopic.php?t=48336

Javascript Code:
it will work for IE
if (navigator.appName == "Microsoft Internet Explorer")
{
var PrintCommand = '<object id="PrintCommandObject" width="0" height="0<br" mode="hold" />CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">';
document.body.insertAdjacentHTML('beforeEnd', PrintCommand);
PrintCommandObject.ExecWB(6, -1); PrintCommandObject.outerHTML = "";
}
else {
window.print();
}
   
Rate this:
Please Sign up or sign in to vote.

Solution 4

You should learn the command language your target printer supports (e.g. ESC/P, ZPL, EPL, etc) to get fast printing performance and then use any of these tools to print at client side without dialog or create one by yourself

qzprint[^]: free or paid options. requires JAVA VM at the client
WebClientPrint[^]: paid, requires jQuery & ASP.NET
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100