locked
Deploying asp.net with crystal report in offline getting print problem RRS feed

  • Question

  • User286910929 posted

    hi...

    Below code is in web.config im deploying my asp.net 2.0 C# webapp in windows 7 OS with crystal report version 10.5.3700.0..
    in my aspx im using printmode="ActiveX"

    <configSections>
    <sectionGroup name="businessObjects">
    <sectionGroup name="crystalReports">
    <section name="printControl" type="System.Configuration.NameValueSectionHandler, System, Version=10.5.1.2285, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" />
    </sectionGroup>
    </sectionGroup>
    </configSections>

    <businessObjects>
    <crystalReports>
    <printControl>
    <add key="url" value="http://localhost:1541/PrintControl.cab" />
    </printControl>
    </crystalReports>
    </businessObjects> 

    Is my above code is correct for CR version 10.5.3700.0
    on clicking print button in CR viewer toolbar Its not printing why whats the problem....?
    I have download cab from http://support.businessobjects.com/CRforVS2008/PrintControl.cab
    and put in my webapp too...

    Thanks in advance..
    Waiting for your reply

    Sunday, October 9, 2011 2:00 AM

Answers

  • User1918766559 posted

    To print the report offline , in the print button_Click try out the following code:

    private void print_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();
            //Create an instance of a report    
         crReportDocument = new Chart();
            try
            {
                //Set the printer name to print the report to. By default the sample  //report does not have a defult printer specified. This will tell the  //engine to use the specified printer to print the report. Print out  //a test page (from Printer properties) to get the correct value.  crReportDocument.PrintOptions.PrinterName = PrinterName;
    
    
                //Start the printing process. Provide details of the print job             //using the arguments.           
      crReportDocument.PrintToPrinter(nCopy, false, sPage, ePage);
    
                //Let the user know that the print job is completed           
      MessageBox.Show("Report finished printing!");
            }
            catch(Exception err)
            {
                MessageBox.Show(err.ToString());
            }
        }
    }
     
    Check a sample :http://aspalliance.com/509_Automatically_Printing_Crystal_Reports_in_ASPNET.all 
     
    http://www.codeproject.com/KB/aspnet/crCode.aspx 
     
    http://www.codeproject.com/KB/aspnet/CrystalReport_DotNET2005.aspx
     
     
     
     
    Thanks,
    Anindita
    http://anindita9.wordpress.com
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 9, 2011 5:35 AM

All replies

  • User1918766559 posted

    Could you please try to produce the error message while trying to print the report by fiddler2 tool.

     Download Fiddler :http://www.fiddler2.com/fiddler2/ 

    basically CRVS2010 only supports the following browsers:

    Internet Explorer 7.0
    Internet Explorer 8.0
    Firefox 2.0
    Firefox 3.5
    Firefox 3.6
    Safari 3.1

    Try the following: 

    1) Enable the "No Printer" option on the report 
    2) Enable the "Dissociate Formatting Page Size and Printer Paper Size" option on the report 

    Details : http://forums.sdn.sap.com/thread.jspa?threadID=1995072 

    Thanks,

    Anindita

    http://anindita9.wordpress.com

    Sunday, October 9, 2011 2:49 AM
  • User286910929 posted

    is this write code what im doing is...

    <configSections>
    <sectionGroup name="businessObjects">
    <sectionGroup name="crystalReports">
    <section name="printControl" type="System.Configuration.NameValueSectionHandler, System, Version=10.5.1.2285, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" />
    </sectionGroup>
    </sectionGroup>
    </configSections>

    <businessObjects>
    <crystalReports>
    <printControl>
    <add key="url" value="http://localhost:1541/PrintControl.cab" />
    </printControl>
    </crystalReports>
    </businessObjects> 

    If i remove above code and used internet in deployment machine then on load of print it ask me to installed business objects resources.bussinessobjects.com/support/download/microsoft/vs_2005/Activexcontrol/printcontrol.cab

    if its give yes then it run fine..
    Most of my deployemnts are not going to be online it will be online so i used the above code...

    Need your help and idea..
    Thanks 

    Sunday, October 9, 2011 5:01 AM
  • User1918766559 posted

    To print the report offline , in the print button_Click try out the following code:

    private void print_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();
            //Create an instance of a report    
         crReportDocument = new Chart();
            try
            {
                //Set the printer name to print the report to. By default the sample  //report does not have a defult printer specified. This will tell the  //engine to use the specified printer to print the report. Print out  //a test page (from Printer properties) to get the correct value.  crReportDocument.PrintOptions.PrinterName = PrinterName;
    
    
                //Start the printing process. Provide details of the print job             //using the arguments.           
      crReportDocument.PrintToPrinter(nCopy, false, sPage, ePage);
    
                //Let the user know that the print job is completed           
      MessageBox.Show("Report finished printing!");
            }
            catch(Exception err)
            {
                MessageBox.Show(err.ToString());
            }
        }
    }
     
    Check a sample :http://aspalliance.com/509_Automatically_Printing_Crystal_Reports_in_ASPNET.all 
     
    http://www.codeproject.com/KB/aspnet/crCode.aspx 
     
    http://www.codeproject.com/KB/aspnet/CrystalReport_DotNET2005.aspx
     
     
     
     
    Thanks,
    Anindita
    http://anindita9.wordpress.com
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 9, 2011 5:35 AM