?
Solved

How can I print an RTF document from C#?

Posted on 2008-10-17
7
Medium Priority
?
3,978 Views
Last Modified: 2012-05-05
How can I print an RTF document from C#? I need to be able to print out the document with all the correct formating, including colors, margins.....
0
Comment
Question by:guxiyou
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 total points
ID: 22742543
0
 

Author Comment

by:guxiyou
ID: 22742908
Is there a way to do this without relying on having an external program that is setup to handle the file type? The reason I ask is that I really need this to work with batching.... and I don't want to have word (for example) open and close a hundred times in order to accomplish this.
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 2000 total points
ID: 22743123
The Process component hides this complexity for you.

For example, if the Process components handles a .xls file, it will automatically be associated with Excel. So if you launch the Print command on this file, Excel will handle the Print command. It act exactly has if you right-click a file in Windows Explorer and select the Print menu command.

If you don't want to have the application opened and closed for you, you will need to use Automation to load documents yourself, print them, and close the application when you are done.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:guxiyou
ID: 22743502
I guess the root of my question is, how can I do this without using the application? It seems like there should be a control or class in .Net (or that someone has done) that would let you print RTF files directly, without the need of having another application installed.  I know there is plenty of code that will allow you to print the contents of a RichTextBox, which is very similar, but does not preserve stuff like margins....
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 22743954
>>I guess the root of my question is, how can I do this without using the application?

There isn't. Each application requires a special formatting (you don't print a Word document like you print a Visio document).

There are probably some third party components out there (I think of Aspose) but are you ready to buy them?

All other utility you will find will surely use Word Automation in the background.
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 22745577
You could call (shell out to) WordPad (which exists on any Windows machine) like this:

wordpad /p d:\path\yourfile.rft

to print directly to the default printer.

/gustav
0
 

Author Comment

by:guxiyou
ID: 22790823
Is it possible to use the process method to print from a webservice?
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Companies keep a much closer eye on costs today, so changing to new Technology – Microsoft Office 365 is the smartest move to take.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question