简体   繁体   中英

Printing A Report (Crystal Report) From Web Page (developed in ASP.NET/VB) Without Directing It To PDF

I'm using Visual Studio 2008 and SQL Server 2000 as a back end and the reporting software we do use for the company's reports is either Crystal Report 9 or Crystal Report 7.

The (ReportViewer.aspx) page, I've set the Print Mode property of the Crystal Report Viewer Control to PDF as there are only two properties PDF and ActixeX

So here comes the problem, if the user clicks the print button of the ReportViewer.aspx ![enter image description here][1]Page it directs to a PRINT THE REPORT page which asks the user the page range he/she wants to prints;![enter image description here][2] Then it'll automatically download a pdf copy of the report the user wanted to print, and the user should then open the downloaded pdf file and print it from there.![enter image description here][3]

This is absolutely a very long process and the users (Company Staff) as well the managers and even me aren't fond of it, I tried to google it and its may be my little knowledge of the field, so I found out this stuff which is referring to Visual Studio 2005 and not 2008

  • ' - ' - ' Printing using the ActiveX control ' - ' - '-

In recent versions of Crystal Reports, you can specify the print mode using the new CrystalReportViewer.PrintMode property. It contains two enumerated types: ActiveX, and PDF.

When the property is set to PrintMode.PDF, the report is exported as a PDF on the Web server, and then streamed to the browser. The user is given the option to print directly to the printer. This option is cross-platform compatible.
When the property is set to PrintMode.ActiveX, an ActiveX printing control allows users to print the report directly to their local printer.

    Note   In Crystal Reports for Visual Studio 2005, the ActiveX print control is not installed on the local machine, in order to meet Microsoft security requirements. Instead, it must be accessed as a .cab file from an external URL. The PrintControl.cab file can be downloaded from the Business Objects tech support Web Site, at which point you can place the cab file in a web server virtual directory for URL access.

    To make the cab file visible to your Crystal Reports for Visual Studio 2005 Web Site, add the following xml to your Web Site's web.config file: 

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

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

    Note   Only Internet Explorer supports ActiveX controls. Printing from a non-Internet Explorer client (FireFox, Safari, Mozilla, and others) reverts to the PDF export dialog.

' - ' - ' - ' - ' -

I'd really appreciate if any one can help me, print the report after hitting the print button of the report viewer instead of directing it to pdf which is a very long way.

如果在按下打印按钮时使用ActiveX,它将自动打印,但需要在Users PC中安装Crystal Control

Hide the print button in the crystal toolbar and then,
put a your own button and then this code:

CrystalReportViewer1.ReportSource = CrystalReportSource1

CrystalReportSource1.ReportDocument.PrintToPrinter(1, 1, 1, 1)

PrintToPrinter:

Prints the specified pages of the report to the printer selected using the PrintOptions.PrinterName property . If no printer is selected, the default printer specified in the report will be used.

Check out Report Runner Batch and Report Runner Event Server. They are commercial products created to handle this task with ease. You'll be able to do more than print, too.

http://www.reportrunner.com

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM