How to? : (ReportViewer + asp.net + .rdlc + print button)

Is there a way to add a Print button to the ReportViewer control in an .aspx page when using .rdlc file

Would the Print button displayed and enabled if I use remote reports(.rdl) instead of local ones(.rdlc)

Response is very much appreciated.

Thanks,

S




Answer this question

How to? : (ReportViewer + asp.net + .rdlc + print button)

  • RonSchlegel

    Hi sorry for this question after a long time,
    I am in a desperate condition to solve the problem that u were talking about. Could u please give sample code for converting to temp EMF file and the javascript code.
    Thanks in advance.

  • yunyuaner

    Yes, here is is:

    http://msdn2.microsoft.com/en-us/library/ms252091(VS.80).aspx

    Or, just google "print from reportviewer control"


  • Karthik.N.Rao

    This is for window app, what I am looking for is in web app...

    But I am trying to convert it to JPG as CTGUY67 said in the earlier post.




  • Charles Chung

    The report viewer web control does not have built in print functionality when in local mode. A print button is available in remote mode.

    The problem isn't the ability to generate EMF files for printing, it's in the availablity of the ActiveX control. In server mode, the viewer sends the ActiveX control from the report server to browser. You can implement your own print functionality and print button by programmatically rendering to EMF (ReportViewer.LocalReport.Render()).


  • DesperadoMike

    Thanks for your quick reply

    I will try it.





  • Stefan Burwitz

    When i try to create a jpeg file, it gives me unhandled exception. Can you send me the code you are using for JPEG file conversion Thanks in advance.
  • RobertMahon

    Thanks Brian!

  • reybhoie

    Oh, thank you for bringing that to my attention. The app I'm creating may run into that issue -- I'm not sure, since we'll be running it under Terminal Services, and I haven't tested it on the server yet. You've given me a heads up if I do hit a snag. Thanks!!
  • Jonathan Lo

    Did you figure this out yet I have a similar situation. I've kind of cluged something together, but I'm not happy with it.
  • zaxxys

    Okay, so I can render the local report to EMF. Now, how do I send it directly to the printer without passing GO I want the report to render to EMF, without hitting the print dialog, and head directly to the default printer. The EMF works great as long as my printer is the Office Document Image Writer.  I want the printer to be something like an HP printer.

  • jet su

    Yeah I was affraid it was going to be that one. I found that one too. It has 2 problems. It creates a temparary EMF file which brings security into play. Secondly, it's server code, so if you're project runs on on a remote server, even though the report runs local, the list of available printers is what's installed on the server.

    The solution I came up with does not create a temp emf file, it converts the memory stream into a jpg. Then Transfer control to a page with a asp:image control. Server code loads the asp:image with the newly created jpg file, and javascript onload does a window.print(); which pops up the local windows printer dialog box.

    The only thing I don't like about my solution is it creates a temp jpg file. I just found the emf files too hard to work with.

    Thanks anyway.


  • TarPista

    You wouldn't happen to have the link to the code on the MSDN site would you
  • kimoz

    The information is at this link:

    http://msdn2.microsoft.com/en-us/library/ms252091(VS.80).aspx

    Or, just google "print from reportviewer control"

    I have no javascript code.

    J


  • scottd_arch

    I figured it out on a whim, by playing with it.

    MS has a print routine on the MSDN site that prints to the MS Office Document Image Writer as the name of the printer set to a Const variable.

    What I did was comment out the constant, comment out the portion of the code that assigns the constant to the printername property of the printdocument, because then the object will take the default printer that is set on the local computer. Because I commented out the set printer portion, I also commented out the portion that checks to see if the printer exists on the local computer (yeah, I know, commenting out error-checking code is not the best practice, but if the default printer is used, well...)

    I left the addhandler of the printpage event, and the addressof portion, then called the print method. What do you know, it worked like a charm!

    I'm not claiming to understand why it works, but hey, it works.

    Hope this helps you out!


  • How to? : (ReportViewer + asp.net + .rdlc + print button)