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.
Related
In my sample web page, there have print option. I need to call that,
<b> Print </b>
because I need to save above page as PDF(My major requirement is to save that page in PDF format). When I try to do it manually following popup window shows.
I need to do it through chrome C# selenium web driver. How can I do it? Please provide me sample code to solve this problem.
You'd use send keys to CTRL+P on the webpage then use driver find element by and then click
Send keys documentation found here:
https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys.send?view=netframework-4.7.2
//This should work for clicking the save/print button without seeing your code I cannot test it.
driver.FindElement(By.XPath("//*[#id="button-strip"]/button[1]")).Click();
The print window is os realted component and you cannot automate them with selenium itself. You may need additional library to automate that along with your selenium code.
You are two Nuget package to it. One simply use InputSimulator and do key inputs like
Or
Automate browse window usings AutoITX nuget package.
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?
I have to save webpage as image by passing page URL,i have found one solution on this thread Convert webpage to image from ASP.NET[^] but it doesn't give me proper image(e.g. tried URL http://www.bugmuncher.com/).
Also tried HTML to Image in C#[^] but not able to deal with IViewObject interface ,basically not able to add reference to get this interface.
I have to do something like http://www.usersnap.com does.I made it work on FF,Chrome and IE9 by using canvas element which is unfortunately not supported by IE8.
Can i get proper working solution for my need???
i think you mean taking a screenshot.
Here you are a link about it.
Capture screenshot of active window?
But here i found on the site that just you want. Please check it.
Convert webpage to image from ASP.NET
The webpage can be saved as image by 2 methods.
1. Press ctrl+p
2. Select "Send to onenote" in print prompt window.
3. Press ok.
Now the image can be saved from the microsoft office -> microsoft onenotebook and rightclick on your content. save as the image file.
Second method is by using snapshot via snipping tool.
I'd like to know of any tools to generate a report in wpf.
What I want to do is to generate the report and export it immediately to a pdf, csv or just print it. I don't want the client to be able to "adjust" the report from within my application. Also the report tool should give me lots of freedom, since I'm geerating reports from a datagrid that is constantly changing, according to the user's commands (in other words .. it's dynamic)
Does anyone know of any tools that allow me to do that (preferably an open source tool, but I'm not tied to it being open source)?
Reporting isn't specific to WPF. You can look at Crystal Reports, SSRS Reports (both server *.rdl and client embedded *.rdlc), or tools from companies like DevExpress' XtraReports.
The +1 for using SSRS Reports is that there appears to be a Mono project that will allow you to render them, so you're not tied 100% to the Microsoft server stack, if you have that requirement. Look at FYI Reporting from the provided link.
If you are familiar with crystal reports, this may be useful to you. Otherwise you could always use xslt and xml
This answer makes a a compelling arguement for micrsoft or third party reporting compared to xslt "hand made" reports.
Edit: As a first go, it may be adviseable to use the crystal report creation wizard
You can use Crystal Reports, just like we use it in WinForms.
You have several options here.
You can print a visual to pdf using a virtual printer: http://www.pdfforge.org/products/pdfcreator.
There are also XPS to PDF converters.
And, of course, there are numerous WPF based report generators.
You're question is quite clear, so I wasn't sure what exactly you were after.
You may consider using ActiveReports to fulfill your reporting needs as ActiveReports has a viewer and end user report designer control which can work quite well in WPF environment.The End user designer control will also allow your end users modify reports at their will.
Regarding the exporting capabilities , ActiveReports will let you export to PDF,Excel,Word,Tiff,Jpeg,Text etc.And lastly activereport will give you the flexibility you are looking for as it can be bound to datasets,XML,OLedbm,sql,Excel sheets, text,array, objects etc ..
You can visit these links to know more how ActiveReports works on WPF:
http://blogs.gcpowertools.co.in/2011/11/how-to-view-report-created-using-active.html
http://blogs.gcpowertools.co.in/2011/08/how-to-host-active-reports-end-user.html
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.