Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all

I am printing a text file from my application using c# code.
now i want 1.5 line space between lines.

Please tell me how to do that using c#.

Thank you
Posted
Comments
Tejas Vaishnav 17-Dec-14 7:05am    
Text file has no property to set like line-spacing, so you need to achieve it manually by providing line break character (\r or \n) at the end of your line.
Black_Rose 17-Dec-14 7:11am    
ya i know that..but i need specific point of spacing line ms-word.
Tomas Takac 17-Dec-14 7:31am    
How are you printing the text file?
Maciej Los 17-Dec-14 8:08am    
Do you want to print them or do you want to save them with custom line-spacing?
Black_Rose 17-Dec-14 22:16pm    
I want to save and then print the same.

Text files are just a convention: they have no "real" concept of lines at all - that is provided by the application which processes them, by looking for what it considers as "line end characters". And these vary from system to system (and can even bee application specific in some cases). In all other matters, they are binary data which uses a limited set of the available values.

So the concept of line spacing is not something a text file can work with: if it doesn't know what a "line" is, it can't space it!

If you are trying to read a .TXT file into you application and display it then exactly how you change the spacing depends on the control you are using to display the data. For a multiline textBox, I don't think it is possible, for a RichTextBox it's pretty simple: Changing the line spacing in a RichTextBox control[^]
 
Share this answer
 
Comments
Black_Rose 17-Dec-14 7:24am    
Thanks for your reply griff..

Just want to is there any process we can specify specific line space value.
e.g. 0.75 or 1.5 etc
OriginalGriff 17-Dec-14 7:29am    
Did you read any of what I wrote?
Black_Rose 17-Dec-14 7:30am    
Yes.But u mentioned textbox and all which i am not using..

i am using streamreader to put data in a .txt file.
OriginalGriff 17-Dec-14 7:39am    
And what part of it did you not understand?
To print text files, you can use PrintDocument class[^] (WinForm), which enable to set several properties.
It's impossible to set "line-spacing" during the save process. Text file does not contains information about formatting (see solution 1).

Another way to format text is to use html[^] + css styles[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900