C# printing rdlc report unattended - c#

I am working on a C# WinForm application that currently has several RDLC reports in it, and those reports need to print at a given time without any user interaction.
The good news, is I found code to do that at Printing A Local Report Without Preview
Unfortunately, while that works fairly well, when it prints, it puts up a small window saying "Printing page x of y" - is there any way to hide/suppress that window, so it can print silently while the user continues to work within the application?

Never mind - I found the solution on my own:
Turns out all you need to do is add the following line before doing the printDoc.Print in the code:
printDoc.PrintController = new StandardPrintController();

Because you are using PrintDocument you can use this solution:
How to skip the dialog of printing in printDocument.print() and print page directly?

Related

Conversion to Word, pdf of Report Server Project (rdl) does not wrap correctly

I am working with report server project in Microsoft Visual Studio 2008 for the first time ever and I am having some problems. Report is rdl and it was made by someone else I have no idea how and when. I have to customize it to work differently. I have only VS 2008 so I imported report and it looked ok in viewer and also converted to word.
After I made some changes, added a row group and one new text box (i have no idea how to add new child row group, that option is unavailable for some reason) report is working fine and it looks fine in report Preview. But now it looks awful converted to word. In word it has no right margin and it goes off the page on the right side. It's seems by adding new row group wrapping is all twisted. That does not happen in Preview.
Did anyone had similar problem? What could be the issue here and how to resolve it? Is it possible to make row grow just vertically but not horizontally?
This is how it looks like exported to Word file (notice how right margin is gone and wrapping is bad)
Its hard to help without attaching some screen shots.
From my experience converting to PDF is usually ok (blank pages can be because of linking too much bands to each other).
Converting to DOC/word is other story and a screen shot of the problem might help

ASP.NET Crystal Report Print Automatically

I would like to know if exists the way to send a crystal report directly to the printer without print dialog. Ex. I have an asp.net page with a crystal report viewer and I want send to print once the report have been loaded into the viewer.
I saw an application what it is doing that but I don't know how that work.
I am using
Visual Studios 2010
Crystal Report for .NET Framework (Version=13.0.2000.0)
C# 4
if have a code sample (will be great!!!!)
I have read lot of resources in internet but nothing give me idea how to do what I need.
Thanks in Advance.
J.S.
It does not working like you think. Method PrintToPrinter generates printout directly to printer. Report preview also do the same. If you are executing both methods then report is generating twice. If you have more pritnout pages then report preview generates only visible pages. In most cases this does not change anything, but if report is generating a lot of time, then you are getting a lot of resources from system and you can expect deadlock on database. You also have to remember that if your report is generating new data per each executing then you will have doubled data.
Good I did it
I Just set this values to the ReportDocument.
CrystalReportDocument.PrintOptions.PrinterName = "Printer Name";
CrystalReportDocument.PrintToPrinter(1, true, 1, 1);
anyways I am open to other ideas and suggestion.

What's the best method to print from my C# program?

I have written a winform program that gathers information from several database tables and displays this information in a datagridview. The user likes it a lot, but they've requested an additional feature: the ability to print the information in the datagridview to their printer.
All of the data that the user wants to print is in the datagridview. If you had to make this kind of change to this program, what method would you use to get the information to the printer?
codeproject's got a bunch:
The DataGridViewPrinter Class
Printing of DataGridView
Another DataGridView Printer
Printing a DataGridView on DotNet Framework
DataGridView Print/Print Preview Solution - Part I
DataGridView Print/Print Preview Solution - Part II
Plus more. I haven't tried any of these myself though.
One way of doing that nicely, if you are able to, is create/design a local report (.rdlc) and print that report without showing the ReportViewer control. An example of that is here.

Crystal Reports load depending on its mood

I have a crystal report viewer on Windows forms.
The report viewer has one report associated with it. I pass 24 parameters programatically. When i try to run the program, sometimes the reports shows and sometimes the software hangs up.
I m passing same data every time to the report. There are no compile time errors. When I do step-debbuging, then every time the report loads perfectly and there are no hang-ups.
What can be reason of this moody opening of report ????
Edit1:
During step debugging, I found that assignment of reportsource to CrystalReportViewer causes the software to hangup.
goldBillReport = new GoldBill();
crystalReportViewer1.ReportSource = goldBillReport; //Hangs after this !!
SetGoldParameters();
Edit 2:
I have changed the scenario now, I take simple windows form, add a crystal report viewer to it. Secondly I create a blank crystal report.
Now I write the following lines in form load event of the windows form which contains viewer.
goldBillReport = new BillReport();
crystalReportViewer1.ReportSource = goldBillReport ;
80% of times when I load the form it shows the blank report (as required). The remaining time it shows nothing and application just hangs. Why ?
Note: My real application is very large. Is it the problem that the program is not getting proper memory space to open the report. If yes then are there any ways to collect garbage ?
Thank you in advance
I would check that you are correctly disposing of your viewer when the form is closed.
Also, I had an issue where the first time I ran a report it was extremely slow. The solution to this was to load a temp report during Application startup (behind a splash screen). This ensured that the Crystal Report DLL's were fully loaded before the user can generate a report. After I did this the reports loaded in few seconds each time.

Printing in Winform Application

I have a C#.NET Winform Application, using which, printing of bills etc. would be done.
But the printing would be done by users using a DMP printer.
So is it possible to send the print to a DMP printer in winform application. If yes, then how?
Also, i have a DataGridView in a Form. Now I want to Print that table which is displayed in the gridview. How do i do this? Will I have to use Crystal Reports or else?
Well not sure this answers you well but i would use PDF Sharp or Migra doc to genereate pdf file from your data and print from there, this way i would not have to do Printer DMP settings (I guess)
The easiest and quickest solution is to use the Visual Basic PowerPack's PrintForm control (You can use it in C# projects as well).
http://msdn.microsoft.com/en-us/vbasic/bb735936.aspx
Just drag the control on to your form then from code call
printForm1.Print();
This will print whatever is on the form, so just design your report on a form then call that code, and you're done.
look at Print the form (Visual C #) you can also use VB power Pack
u can only do code like in C# to print any document or page.
PrintDialog p1= new PrintDialog ()
p1.ShowDialog();
I would use visual studio's emmbeded control calles "ReportViewer" control.
You can find it under "Reporting" section in the toolbox .
Please note that you need to have an app that target's framwork 3 and above for you to see this control.
In this control you can Print to selected printer , export to pdf,word and excel.
Check it out.
I do know there's already an accepted answer but I wish to add a new link to a youtube tutorial that i found recently. Print receipt
Cheers.

Categories

Resources