Count lines in rtf files with c# [modified]
-
Hi all, I am trying to find a way to count lines in an rtf file, so I could later create a kind of paging. I am using c#, also is there a way to show a string that includes format characters (such as "/par" in rtf) in a richTextBox? Thanks!!! Panos
modified on Thursday, March 13, 2008 1:59 PM
-
Hi all, I am trying to find a way to count lines in an rtf file, so I could later create a kind of paging. I am using c#, also is there a way to show a string that includes format characters (such as "/par" in rtf) in a richTextBox? Thanks!!! Panos
modified on Thursday, March 13, 2008 1:59 PM
panoskatws wrote:
Hi all, I am trying to find a way to count lines in an rtf file
There may be a library that will do that for you, I don't know. Otherwise to write your own code to do anything with a specific file format you start by learning the file format. So if that is what you intend to do then go find some documentation for the RTF file format and learn it.
led mike
-
Hi all, I am trying to find a way to count lines in an rtf file, so I could later create a kind of paging. I am using c#, also is there a way to show a string that includes format characters (such as "/par" in rtf) in a richTextBox? Thanks!!! Panos
modified on Thursday, March 13, 2008 1:59 PM
-
panoskatws wrote:
Hi all, I am trying to find a way to count lines in an rtf file
There may be a library that will do that for you, I don't know. Otherwise to write your own code to do anything with a specific file format you start by learning the file format. So if that is what you intend to do then go find some documentation for the RTF file format and learn it.
led mike
Well about libraries I haven't found anything that I can use. So I must create my own piece of code that counts lines and takes specific parts of formated text and display it in a RichTextBox, formated... That is an other problem I have, don't know how to display a part of formated text without loosing the styling(fonts, colors etc.). All special characters are displayed with the text (/n ...). So I understand that I must learn about the rtf file format. Does anyone know the basics that are needed, or any suggestions??? Thanks!!!
-
The RichTextbox not working for you?
xacc.ide - now with IronScheme support
IronScheme - 1.0 alpha 2 out nowIt's working fine, but I have a problem with displaying the text formated from a string variable. For example if |I have a string with the following text :"{\rtf1ansi\ansicpg1253\deff0\deflang1032{\fonttbl{\f0\fnil Arial;}}{\colortbl\red0\green0\blue0 ;\red240\green248\blue255 ;}\viewkind4\uc1\pard\cf0\fs40\f0\b\ul Title\par\par\fs24\b0\ul0 This is a test.\cf1 This is a text.\par\par}" how can I display the text formated, without having to figure out all the special characters? Is there any method or function that I can use in visual studio 05?
-
It's working fine, but I have a problem with displaying the text formated from a string variable. For example if |I have a string with the following text :"{\rtf1ansi\ansicpg1253\deff0\deflang1032{\fonttbl{\f0\fnil Arial;}}{\colortbl\red0\green0\blue0 ;\red240\green248\blue255 ;}\viewkind4\uc1\pard\cf0\fs40\f0\b\ul Title\par\par\fs24\b0\ul0 This is a test.\cf1 This is a text.\par\par}" how can I display the text formated, without having to figure out all the special characters? Is there any method or function that I can use in visual studio 05?
panoskatws wrote:
It's working fine, but I have a problem with displaying the text formated from a string variable.
Be more specific. 1) Are you having a problem displaying the text with formatting in the RichTextBox control? If so provided details regarding the problem. 2) Are you saying you want to display it in some way other than using the RichTextBox? If so provide specifically how you want to do that.
led mike
-
It's working fine, but I have a problem with displaying the text formated from a string variable. For example if |I have a string with the following text :"{\rtf1ansi\ansicpg1253\deff0\deflang1032{\fonttbl{\f0\fnil Arial;}}{\colortbl\red0\green0\blue0 ;\red240\green248\blue255 ;}\viewkind4\uc1\pard\cf0\fs40\f0\b\ul Title\par\par\fs24\b0\ul0 This is a test.\cf1 This is a text.\par\par}" how can I display the text formated, without having to figure out all the special characters? Is there any method or function that I can use in visual studio 05?
2 ways: 1. Place the string in a MemoryStream, then Load the stream, the RichTextBox should detect it is RTF. 2. Place the string in the clipboard, set its format to RTF, then paste that object to the RichTextBox. I wouldnt normally suggest a way like #2, but as the 1st method will overwrite all the current content (and that may not be desirable), I do mention it.
xacc.ide - now with IronScheme support
IronScheme - 1.0 alpha 2 out now -
It's working fine, but I have a problem with displaying the text formated from a string variable. For example if |I have a string with the following text :"{\rtf1ansi\ansicpg1253\deff0\deflang1032{\fonttbl{\f0\fnil Arial;}}{\colortbl\red0\green0\blue0 ;\red240\green248\blue255 ;}\viewkind4\uc1\pard\cf0\fs40\f0\b\ul Title\par\par\fs24\b0\ul0 This is a test.\cf1 This is a text.\par\par}" how can I display the text formated, without having to figure out all the special characters? Is there any method or function that I can use in visual studio 05?
If I understood you correctly, you can set the
Rtf
property of aRichTextBox
to this string and then you can get lines count throughLines.Length
.Greetings - Gajatko Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.