joaocarlospf
joaocarlospf

Reputation: 1157

What's the best way to generate a file and print it in .net?

I am working in a desktop project in C# with .net. This project has a function that generates some information and i would like to print this generated info as a document (may be .doc, .pdf, etc). Summarizing, i need:

  1. Get the data generated by a function;
  2. Generate a document containing these information structured with title, texts and tables (things that every document have);
  3. Print it;

I thought generating an .html file (because it's simple to generate this kind of file), but i couldn't find a way to print it directly from my program.

Which extension of file would you recommend to insert this kind of information and print it directly from my program??

Thanks in advance.

Upvotes: 0

Views: 1133

Answers (2)

Roman Pokrovskij
Roman Pokrovskij

Reputation: 9776

Directly? Open printer port...

Or you can do it with framework classes:

How to: Print with a WebBrowser Control http://msdn.microsoft.com/en-us/library/b0wes9a3.aspx

Upvotes: 0

Lou Franco
Lou Franco

Reputation: 89232

Here's an easy way that uses a RichTextBox

http://www.codeproject.com/KB/printing/simpleprintingcs.aspx

It's not trivial to print a PDF, HTML, or a doc unless you are going to use external programs or third-party libraries. ImageMagick/GhostScript could help you print PDF.

Disclaimer: I work at Atalasoft -- If you are willing to use commercial software, my company makes PDF rendering components for .NET. There are companies that do the same for HTML.

Upvotes: 1

Related Questions