TOP KEK
TOP KEK

Reputation: 2641

Approaches to print a document in C#

From time to time we all need to print a document from our .NET programs. Let's say a simple one page document with some text and image.

So far I know 2 ways to do it:

  1. Using standard PrintDocument class
  2. Generate a pdf/doc document using such tool like PdfSharp

First way I don't like because it takes a lot of time to write all these routines for handling events and standard PrintPreviewDialog is just ugly. Beside that you need to generate and scale 2 different documents on print preview and actual printing.

Second way bothers me because these free components quite often are limited and poorly documented.

What other solutions for printing do you know?

Upvotes: 2

Views: 380

Answers (3)

Jan Blaha
Jan Blaha

Reputation: 3095

I have tried to analyze possible options in the article pdf reports in c#.

  • iTextSharp - imperative way of doing reports in c#, (-) produce not very readable code
  • Telerik Reporting, DevExpress reporting, Crystal Reports - similar approach, report editor, great for simple job, able to produce multiple formats, (-) harder to team merge and print complex reports
  • phantomjs, wkhtmltopdf - html to pdf conversion, (-) extra dependency
  • jsreport - my solution, javascript templating engines to assemble html report and phantomjs to print it into pdf (-) overhead for simple solutions, extra dependency

Long story short. I was not satisfied with the current options and developed jsreport as a solution for designing and printing pdf reports. Check it out, it's free.

Upvotes: 1

Peter
Peter

Reputation: 14098

I haven't seen an elegant printing solution in .NET yet, except for WPF and XPS. In that case, you can just create a UI in Xaml and print it. But XPS isn't often a viable option. I've worked with XSL-FO also (using NFop and later FO.Net - the latter is better because newer and it doesn't require Visual J#), which works but has a moderately steep learning curve.

Upvotes: 1

Nikhil Agrawal
Nikhil Agrawal

Reputation: 48558

use Crystal Reports for printing. Best Option IMO

Upvotes: 2

Related Questions