ASP.NET - problem in printing directly from web application in

Asked By mani on 24-May-12 04:21 AM
hi..any one help me to pirnt directly from crystal report to client printer in from web application with out showing in pdf fromat..please any one give perfect solutions..??
Jitendra Faye replied to mani on 24-May-12 04:34 AM
YOu can simply use PrintToPrinter() method for this.

use thid coce-

private void button2_Click(object sender, System.EventArgs e)
    //Open the PrintDialog
    this.printDialog1.Document = this.printDocument1;
    DialogResult dr = this.printDialog1.ShowDialog();
    if(dr == DialogResult.OK)
    //Get the Copy times
    int nCopy = this.printDocument1.PrinterSettings.Copies;
    //Get the number of Start Page
    int sPage = this.printDocument1.PrinterSettings.FromPage;
    //Get the number of End Page
    int ePage = this.printDocument1.PrinterSettings.ToPage;
    //Get the printer name
    string PrinterName = this.printDocument1.PrinterSettings.PrinterName;

    crReportDocument = new ReportDocument();
    ======YOUR CODE==========
    crReportDocument.PrintToPrinter(nCopy, false, sPage, ePage);


TRy this and let me know.
Somesh Yadav replied to mani on 24-May-12 04:44 AM

Clicking print button will raise the print popup window from the browser. That's the general behavior. I can not find a perfect resolution for your answer, but try following script, you will be able to customize for need. This works for IE but not other browser.

Uncomment the sup print() procedure before executing.

kalpana aparnathi replied to mani on 24-May-12 06:28 AM

Try below code:

private void Button1_Click(System.Object sender, System.EventArgs e)
    PrintDocument prtdoc = new PrintDocument();
    string strprint = prtdoc.PrinterSettings.PrinterName;
    string strPrinter = null;
    foreach (string i in PrinterSettings.InstalledPrinters) {
        strPrinter = i;
        if (strPrinter == strDefaultPrinter)
            //ComboBox1.SelectedIndex = ComboBox1.Items.IndexOf(strPrinter);