locked
Printing .rtf Documents in the Background RRS feed

  • Question

  • Does anyone know of a way to print .rtf documents in the background? The below code will print a .rtf, but only after opening Word (or more generally, the application associated with *.rtf) and its print dialog. I would like to accomplish this by sending the print job straight to the printer without launching any other applications. Thanks in advance for any help.

        Process printProcess = new Process();
    
        printProcess.StartInfo.FileName = absoluteRTFPath;
        printProcess.StartInfo.Verb = "Print";
        printProcess.StartInfo.CreateNoWindow = false;
        printProcess.Start();
    


    Thursday, May 21, 2009 8:34 PM

Answers

  • Load your RTF file into a RichTextBox and print it using the sample you find by searching MSDN for "Print RTF" or "Print RichTextBox".
    • Proposed as answer by Harry Zhu Friday, May 29, 2009 1:56 AM
    • Marked as answer by Harry Zhu Sunday, May 31, 2009 7:18 AM
    Thursday, May 21, 2009 9:00 PM
  • Hi,
    Using RichTextBox is better way to do the work,however, we do not need to embed the control in a Windows Form to perform this kind of operation.

    http://msdn.microsoft.com/en-us/library/cc488002.aspx

    Harry
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Proposed as answer by Harry Zhu Friday, May 29, 2009 1:56 AM
    • Marked as answer by Harry Zhu Sunday, May 31, 2009 7:18 AM
    Monday, May 25, 2009 6:52 AM
  • Does anyone know of a way to print .rtf documents in the background? The below code will print a .rtf, but only after opening Word (or more generally, the application associated with *.rtf) and its print dialog. I would like to accomplish this by sending the print job straight to the printer without launching any other applications. Thanks in advance for any help.   
    rtf-formatted text does not contain any page settings, margins, or selected paper, but I suppose you could make a method to print some text using a default set of parameters.

    But in that case, how would the user select the printer? Are you looking for something to send a print job to the default printer?


    • Proposed as answer by Harry Zhu Friday, May 29, 2009 1:56 AM
    • Marked as answer by Harry Zhu Sunday, May 31, 2009 7:18 AM
    Monday, May 25, 2009 8:36 AM

All replies

  • Load your RTF file into a RichTextBox and print it using the sample you find by searching MSDN for "Print RTF" or "Print RichTextBox".
    • Proposed as answer by Harry Zhu Friday, May 29, 2009 1:56 AM
    • Marked as answer by Harry Zhu Sunday, May 31, 2009 7:18 AM
    Thursday, May 21, 2009 9:00 PM
  • The app that I am working on is itself a background process, so a UI-based solution is not practical. Surely there is a way to print the contents of a .rtf without using an RTB control...
    Thursday, May 21, 2009 11:17 PM
  • Use Windows Presentation Foundation.
    Friday, May 22, 2009 4:23 AM
  • John,

    Is there any WPF functionality that will support printing the contents of a .rtf without actually instantiating any UI controls?
    Friday, May 22, 2009 5:53 PM
  • Hi,
    Using RichTextBox is better way to do the work,however, we do not need to embed the control in a Windows Form to perform this kind of operation.

    http://msdn.microsoft.com/en-us/library/cc488002.aspx

    Harry
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Proposed as answer by Harry Zhu Friday, May 29, 2009 1:56 AM
    • Marked as answer by Harry Zhu Sunday, May 31, 2009 7:18 AM
    Monday, May 25, 2009 6:52 AM
  • Does anyone know of a way to print .rtf documents in the background? The below code will print a .rtf, but only after opening Word (or more generally, the application associated with *.rtf) and its print dialog. I would like to accomplish this by sending the print job straight to the printer without launching any other applications. Thanks in advance for any help.   
    rtf-formatted text does not contain any page settings, margins, or selected paper, but I suppose you could make a method to print some text using a default set of parameters.

    But in that case, how would the user select the printer? Are you looking for something to send a print job to the default printer?


    • Proposed as answer by Harry Zhu Friday, May 29, 2009 1:56 AM
    • Marked as answer by Harry Zhu Sunday, May 31, 2009 7:18 AM
    Monday, May 25, 2009 8:36 AM