This is a migrated thread and some comments may be shown as answers.

Print Report to Client-Side Printer

14 Answers 579 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kwan Choo
Top achievements
Rank 1
Kwan Choo asked on 11 Sep 2008, 04:21 AM
Hi,

I would like to print the report at client side printer. I have gone through those threads but none of those help.
This is my scenario,

I have 10 pages report, when the user gets into this page and click on a button.
The report will be printed directly into the client side printer. I don't want to show up the report in the page which mean there is only a button in the page.

It's ok whether to pop up the printer dialog or not.

Thanks.
KC

14 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 11 Sep 2008, 01:45 PM
Hello Kwan Choo,

Attached you will find a sample web site solution which shows a possible approach how to achieve this functionality. In general you can use the ReportViewer control hidden in a div element and call the PrintReport method of the client side object.

Hope this helps.


Greetings,
Steve
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Vince Smith
Top achievements
Rank 1
answered on 23 Feb 2009, 03:39 PM
I am doing something similar to this, but in my case i also need to close the window.  Calling the printreport on the hidden view works, but it seems that any commands that are added after that call are not executed.  Do you have any thoughts on this?  Is there a way to automatically call the print function and then close the window?

Thanks!
0
Steve
Telerik team
answered on 24 Feb 2009, 03:31 PM
Hello Vince,

I've attached modified project according to your description. Give it a spin and let me know how it goes.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Vince Smith
Top achievements
Rank 1
answered on 24 Feb 2009, 04:03 PM
Thanks, that prints and closes the window, however it is not using the pdf reader to generate the report.  It is actually printing the html version.

I also have tried using the PrintAs("PDF") function, but what I get there is the PDF opens up and when I select print the viewer window remains.  My goal is to have no windows remain after they print.  Any thoughts?  I thought I read that PrintReport() would use the PDF plugin.  I am using version 2.8.8.925 of Reporting.

Thanks!
0
Steve
Telerik team
answered on 24 Feb 2009, 04:25 PM
Hi Vince,

Are you by any chance trying this with Firefox? If this is the case apply the following styles to the div around the report viewer instead: <div style="visibility:hidden;width:1px;height:1px;overflow:hidden;">

Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Vince Smith
Top achievements
Rank 1
answered on 24 Feb 2009, 05:31 PM

This is in IE 7, but the problem is not with the report viewer being visible in the div.  There are 2 issues I see.

1.  PrintReport() is not using the Adobe plugin.  It is trying to print the html report and it is printing a blank page.  I want it to use the adobe plugin.

2.  Using PrintAs("PDF") opens up the adobe reader and leaves it open after printing.

 

Thanks!

0
Steve
Telerik team
answered on 25 Feb 2009, 08:29 AM
Hello Vince,

It seems that there is a problem with the adobe plug-in on your end, as this is working perfectly fine on ours in both cases. I've tested it on two machines and prepared two movies to show you how it behaves on our end.

Best wishes,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Vince Smith
Top achievements
Rank 1
answered on 25 Feb 2009, 11:50 AM
Maybe there is a difference with the Acrobat versions.  What version of Acrobat reader are you using?  I am using version 8.1.2.
0
Steve
Telerik team
answered on 25 Feb 2009, 12:21 PM
Hi Vince,

Adobe PDF Reader versions are different on both machines we tested - 8.1.3 and 9.0.0. Works fine on both as mentioned in my previous reply. However we do not believe that the version is the actual issue, rather a corrupted plug-in, which you might want to completely remove and then install latest available version. Also make sure you do not have other PDF handling programs installed, such as FoxIt Reader.

All the best,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Vince Smith
Top achievements
Rank 1
answered on 25 Feb 2009, 12:32 PM
Thanks Steve, I will give that a try.
0
Stephen McDaniel
Top achievements
Rank 1
answered on 12 Mar 2009, 11:21 PM
I also need this functionality (opening a new window, printing, then closing the window).  I've tried your sample and it does work for me with the simple report.  However, my reports are much more complicated than a single textbox and it seems this causes problems because the popup window gets closed before the report is even done running. 

For example, if I update the files you attached to fake some complexity, the print dialog never comes up (the window closes without any hint of printing).  I just updated the Report1.vb class and added this code:

    Sub FakeDelay(ByVal sender As ObjectByVal e As System.EventArgs) Handles DetailSection1.ItemDataBound 
        'Add a 3 second delay to fake report complexity 
        System.Threading.Thread.Sleep(3000) 
    End Sub 

Any suggestions?

I've tried attaching JavaScript event handlers to the PreviewFrame IFRAME so that I only do the window.close() after the printable report is loaded, but even that didn't seem very reliable because sometimes the Adobe plugin takes a while to load and display the print window even after the IFRAME has finished loading. 

Thanks for any help,
-Stephen
0
Steve
Telerik team
answered on 13 Mar 2009, 08:28 AM
Hello Stephen,

Various reports can have various exporting/printing times required. Currently the only way is to set the timeout to the time needed for the largest report to print and add a couple of seconds on top of it, just to be on the safe side. This is not very reliable, but is currently the only option as there is no way to tell, when the export/print has finished.

All the best,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Rose
Top achievements
Rank 1
answered on 05 May 2011, 06:59 PM
I have spend a few days researching .  I have a web application where I am using

 

 

<telerik:ReportViewer ID="ReportViewer1" runat="server" style="display:none" />

 



 

 

protected void Page_Load(object sender, EventArgs e)

 

 

{


 

 

string printScript = string.Format("{0}.PrintReport(); ", this.ReportViewer1.ClientID);

 

 

 

 

ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", printScript, true);
 .....


to auto print some reports.  Since the Reportviewer is not displayed which is what I want, the generating report progress bar does not display.  Is there a way to show the Generating Reports progress bar.

Thanks
Rose

 

0
Wesley
Top achievements
Rank 1
answered on 13 May 2011, 07:14 AM
Hi,
I used the similar approach for printing in client side from my application.
I m using  Version=3.2.9.1104 of report viewer

 

this.ReportViewer1.Report = oReport;

 

 

 

string print = string.Format("{0}.PrintReport();", this.ReportViewer1.ClientID);

 

 

 

this.ClientScript.RegisterStartupScript(this.GetType(), "PrintReport", print, true);

 



It worked well in dev environment but when deployed in Prod the print failed and showed err message
"ReportViewer1 is null"

Does anyone faced this issue and any  solution to it. Does this PrintReport() script works with 3.2.9.1104 version?

Thanks
Tags
General Discussions
Asked by
Kwan Choo
Top achievements
Rank 1
Answers by
Steve
Telerik team
Vince Smith
Top achievements
Rank 1
Stephen McDaniel
Top achievements
Rank 1
Rose
Top achievements
Rank 1
Wesley
Top achievements
Rank 1
Share this question
or