Direct print

Stimulsoft Reports.NET discussion
Post Reply
burru
Posts: 10
Joined: Fri Jul 18, 2008 5:55 am

Direct print

Post by burru »

HI,
i recently started on using stimulsoft reports. I've been able to build reports as i needed and it seems like the software is exactly what i needed.
I now have a problem on direct printing a report. I read that i can print the report directly on the default printer but i cannot understand how i can print on the CLIENT default printer. I don't need any preview, just direct print when a button is clicked.
I tryed to add a printer definition on web.config on the server but this will print my report on the printer of the server, not the client. At this poin i'm kinda confused... anyone can help me please?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Direct print

Post by Edward »

Hello.

StiWebViewer has PrintToDirect() method for printing. But in this case the print dialog will appear with a default printer selected there.

If you do not want even see that dialog then you can call Print method of the Report directly (printing is possible only on server in that case):

Code: Select all

stiWebViewer1.Report.Print(False)

Thank you.
burru
Posts: 10
Joined: Fri Jul 18, 2008 5:55 am

Direct print

Post by burru »

Hello,
thank you. This solution needs the viewer to be visible. But i don't want to show it to the user, i want something very smart: Button Print -> Print to printer. No viewer, no dialogs, nothing.
It's possible this way?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Direct print

Post by Edward »

Yes, it is possible.

Here is the code for that:

Code: Select all

// when the report is loaded from the report file
Stimulsoft.Report.StiReport report = new Stimulsoft.Report.StiReport();
report.Load("MyReport");
// or it can be loaded from assembly it does not matter.
//Stimulsoft.Report.StiReport  report = Stimulsoft.Report.StiReport.GetReportFromAssembly("myReportAssembly.dll");

// without that the method report will be empty
report.Render(false);

report.Print(false);
Let me know if any additional help is required.

Thank you.
burru
Posts: 10
Joined: Fri Jul 18, 2008 5:55 am

Direct print

Post by burru »

Hi,
i tryed with that code but nothing happens. Is there any demo online that shows that example so that i can try it?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Direct print

Post by Edward »

Please visit

http://web.stimulsoft.com

There stiWebViewer.PrintToDirect methods is working for the Print Button inside of the StiWebViewer.

Does that dialog contain that desired default printer?

Thank you.
burru
Posts: 10
Joined: Fri Jul 18, 2008 5:55 am

Direct print

Post by burru »

Yes, my default printer appear on the dialog when i use "Print without preview".
But... can I print on that printer without that dialog?? I need a button printing when I press it, without dialogs of any kind.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Direct print

Post by Edward »

All above suggestion will work only in the server machine, it is true. On the client machine we only can use the browser possibilities, and printing in that case is very limited.
The best possible way to print the report on the client's side is to print it using the Adobe Acrobat pdf file as a response from the server.
The following command will allow you to have response as pdf:

Stimulsoft.Report.Web.StiReportResponse.ResponseAsPdf(this, report)

This is the best way as all other ways use the browser for printing. And not all HTML representations of the report have the same appearance as the report inside the Windows Forms preview control. So please use this way for complex reports.

Unfortunately there is no build-in solution for printing without dialog window.

As a workaround you may use a Java-Script inside your page or print directly from the server, as it was suggested in the following article:

http://aspalliance.com/509_Automaticall ... ASPNET.all

Thank you.
Post Reply