none
print formatted rich text without a RichTextbox control? RRS feed

  • Question

  • Hi,

    Is it possible to print text like the below without using a form and RichTextBox control?

    My application opens a text file with several lines of tab delimited and newline delimted text, the first line with the Customer data, each subsequent line either has Account Data (starting with 01) or transaction data (starting with 02) like the below:

    CSAclsEN 001 \\sgprt\Projects2 001 CSAclsEN-2010-1130227 16:59 27Feb13 2010 Southgate Branch SS01 001 ****69 Steve Suttill 
    01 ******10  Business Current Account GBP 2,342,188.20 
    02 27Feb13 700.00-  
    02 27Feb13 25.00- Llook at lloyds 
    02 27Feb13 1,000.00-  
    02 27Feb13 1,000.00- fred 
    02 27Feb13 20.00- Cashier Transfer fee 
    01 ******11  Personal Current Account GBP 22,456.80 
    02 27Feb13 100.00-  
    02 27Feb13 1,000.00  
    02 27Feb13 1,234.56 Credit reference looks more cr 
    02 27Feb13 2,222.22  

    I'd like to simply print it but in the format above

    Tuesday, December 24, 2013 10:53 AM

Answers

  • Hi,

    >> My application opens a text file <<

    What do you mean by "application" and “text file”? According to your picture, I assume it is a Word document.

    >> Is it possible to print text like the below without using a form and RichTextBox control?<<

    Yes. As far as I know, if you open a document above with several lines of delimited tabs in Word application, the format will not be broken when you print it. I don’t think you need to use the RichTextBox control to achieve your goal.

    I create a document below and print it.

    However, if the application is a custom one instead of Word, I'm not sure whether the format of the file will be kept when printing it since I don't know how this application works.

    By the way, this forum is to discuss problems of Office development, for more questions about Word client feature, I suggest you posting in the Word IT pro forum for more effective responses.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Wednesday, December 25, 2013 5:10 AM
    Moderator
  • Hi "Bananas"

    I agree that this is probably the wrong forum, and I can move the discussion to a C# forum, but first I'd like to explore another path with you, if you don't mind...

    If you client (bank) wants to print in a rich format, then Word is certainly a candidate. Most people feel comfortable with Word and it's usually installed "everywhere". However, the Word application should not be run server side, which is why Microsoft developed and released the Open XML file formats when Office 2007 was released. These file formats were developed specifically for server-side production of Word documents. You might want to visit OpenXMLDeveloper.org; there's a Visual Studio SDK for working with Open XMl documents: Open XML SDK.

    You could generate RTF files, but that Microsoft file format was deprecated when the Open XML file formats were released. It still works; Word and other software can still read it; the specs should still be available. An RTF file is basically a text file containing RTF mark-up (as opposed to HTML or some other markup). IOW it's possible to generate RTF without needing a forms control or a form.

    It would also be possible for you to generate the files as HTML as those are also essentially text files.

    Lastly, you'd have the option of creating a PDF or XPS file.


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, December 28, 2013 5:05 PM
    Moderator

All replies

  • Hi,

    >> My application opens a text file <<

    What do you mean by "application" and “text file”? According to your picture, I assume it is a Word document.

    >> Is it possible to print text like the below without using a form and RichTextBox control?<<

    Yes. As far as I know, if you open a document above with several lines of delimited tabs in Word application, the format will not be broken when you print it. I don’t think you need to use the RichTextBox control to achieve your goal.

    I create a document below and print it.

    However, if the application is a custom one instead of Word, I'm not sure whether the format of the file will be kept when printing it since I don't know how this application works.

    By the way, this forum is to discuss problems of Office development, for more questions about Word client feature, I suggest you posting in the Word IT pro forum for more effective responses.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Wednesday, December 25, 2013 5:10 AM
    Moderator
  • Hi "Bananas"

    If I understand you correctly, you want to "transform" the text file into a file with formatting (the image in your post). And, since you've posted in a forum for Microsoft Word, you think it might be possible to achieve your goal using Word.

    An open question is, whether you expect to do so with or without writing programming code, as you've posted in a Developer (programming) venue, but your message does not sound as if you want to do any coding...

    If you do not wish to write code, then Luna's suggestion that you ask in a forum that targets end-users is a good one. However, I know of nothing in Word that can reliably transform the text content you show to a formatted content. There is an "AutoFormat" capability, but it's not something you can configure and it certainly will not remove content from the text file, nor insert additional content into it. Therefore, unless you can get the data you show us into a different kind of format, that could be used in mail merge, you will need to write programming code of one kind or another.


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, December 25, 2013 1:23 PM
    Moderator
  • Hi Cindy,

    Thanks for answering.

    I definitely need to do this using code, programming in c#.

    I am definitely on the wrong forum, so want to try and move this question to the c# forum.

    I am enhancing a c# application that currently loads Word templates and pastes data in from tab delimited textfiles that are dropped into a directory by an iSeries - then my application prints the resulting Word document as a receipt or whatever for the customer in my bank.

    Now, I can't use templates as there is an unknown number of accounts to output, with all the transactions in a ministatement format.

    I have been trying like crazy to do this using MS Word and tables, and it sort of works 90% of the time, so I started looking around at different, simpler options for the mini statements (as there are only 3 Bold words per account).

    I thought it might be possible to output the results tgab delimited using two font objects, one for Verdana 10, Normal, and one for Verdana 10, Bold.

    So I asked the question about Rich text. Really I want to try and do this without Word, as my code doesn't work 100% of the time, and I wouldn't be able to use a form or Richtext control as eventually this application is supposed to run as a service, polling the drop directory and creating customer receipts / mini statements on demand when the cashir/teller completes a transaction


    Saturday, December 28, 2013 4:53 PM
  • Thanks everyone for answering.

    I have asked a question on the c# general forum, as my question isn't specifically about Word, because I am trying for this part of the development to find a robust way to do the printing without MS-Word since my code that prints the ministatements using Word, Selection, and Tables is buggy and perhaps the .NET framework and c# offers an option.

    Print rich text without using Word, or Rich Text form control in c# Service

    Saturday, December 28, 2013 5:04 PM
  • Hi "Bananas"

    I agree that this is probably the wrong forum, and I can move the discussion to a C# forum, but first I'd like to explore another path with you, if you don't mind...

    If you client (bank) wants to print in a rich format, then Word is certainly a candidate. Most people feel comfortable with Word and it's usually installed "everywhere". However, the Word application should not be run server side, which is why Microsoft developed and released the Open XML file formats when Office 2007 was released. These file formats were developed specifically for server-side production of Word documents. You might want to visit OpenXMLDeveloper.org; there's a Visual Studio SDK for working with Open XMl documents: Open XML SDK.

    You could generate RTF files, but that Microsoft file format was deprecated when the Open XML file formats were released. It still works; Word and other software can still read it; the specs should still be available. An RTF file is basically a text file containing RTF mark-up (as opposed to HTML or some other markup). IOW it's possible to generate RTF without needing a forms control or a form.

    It would also be possible for you to generate the files as HTML as those are also essentially text files.

    Lastly, you'd have the option of creating a PDF or XPS file.


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, December 28, 2013 5:05 PM
    Moderator
  • yeah, I have asked the question on the c# general forum, as Word hasn't been successful for what I trying to do.Thanks for taking the time to try and help

    Saturday, December 28, 2013 5:06 PM
  • Hi Cindy,

    Well, I say server side, it'll probably be a simple Windows 7 Professional box pretending to be a server for just a few functions like managing Cashier Printing.

    So Word will definitely be available, my problem is I have come up against so many roadblocks due to my very basic and limited unserstanding of the Word Object model, Range object, tables, documents, and so much trouble with the Selection object that I thought I'd explore simple c# alternatives for the mini statement module.

    Saturday, December 28, 2013 5:12 PM