开发者

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

开发者 https://www.devze.com 2023-01-26 07:25 出处:网络
I am working in a desktop project in C# with .net. T开发者_如何学运维his project has a function that generates some information and i would like to print this generated info as a document (may be .doc

I am working in a desktop project in C# with .net. T开发者_如何学运维his 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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号