Hi,
I have to write an application that generates an rtf file. Some parts of the this file must be bold.
What should I do in order to have a string (using c#) be represented bold in the t file?
Thanks,
Bold effect in rtf file
Page 1 of 16 Replies - 5566 Views - Last Post: 27 August 2009 - 10:41 AM
Replies To: Bold effect in rtf file
#3
Re: Bold effect in rtf file
Posted 27 August 2009 - 01:00 AM
Actually i had already implement one code usig \b \b0 options but it doesnt create any different in my output.
StringBuilder builder = new StringBuilder();
//Add the header.
builder.Append(@"{\rtf1\fbidis\ansi\ansicpg936\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fswiss\fprq2\fcharset0 Calibri;}" + "\r\n");
builder.Append(@"{\f1\froman\fprq2\fcharset0 Times New Roman;}{\f2\fnil\fcharset0 Microsoft Sans Serif;}}" + "\r\n");
builder.Append(@"{\colortbl;\red0\green0\blue0;}" + "\r\n");
builder.Append("\r\n");
string header = "Title";
header = string.Format(@"\b {0}\b0", header);
builder.Append(hearder);
richtextbox.rtf = builder.ToString();
#4
Re: Bold effect in rtf file
Posted 27 August 2009 - 01:11 AM
yes core have given you a good stuff you must see that.any way you asked how to do it in C# it could be done using Font class
Ok try to understand what I am doing ,First in C# create a windows application then on the form add a richtextbox and add this text from properties window " We are in DreamInCode " then go to the form load event and add this code.
Hope you will get some idea from this code
Ok try to understand what I am doing ,First in C# create a windows application then on the form add a richtextbox and add this text from properties window " We are in DreamInCode " then go to the form load event and add this code.
//Create a Font to set the selected text font
Font font = new Font("Arial", 8,FontStyle.Bold);
//Select the text
richTextBox1.Find("DreamInCode");
//Set the font
richTextBox1.SelectionFont = font;
//Save it in *.rtf format
richTextBox1.SaveFile("C:\\mytext.rtf");
Hope you will get some idea from this code
#5
Re: Bold effect in rtf file
Posted 27 August 2009 - 02:08 AM
Thank you.
Its realy being help to me . Thakns a lot.
Its realy being help to me . Thakns a lot.
#6
Re: Bold effect in rtf file
Posted 27 August 2009 - 03:14 AM
Debjit Can you please give me some glims how to add new blank line in rich text box ?
#7
Re: Bold effect in rtf file
Posted 27 August 2009 - 10:41 AM
In MSDN you will find every thing about RichTextBox.And for adding a new line use special characters in a string by using escape sequences,like "\n" for newline
Good luck
richTextBox1.Text = "In DreamInCode\n"; richTextBox1.Text += "\n";//Adding a new blank line richTextBox1.Text += "Hope you got it";//Adding a new text
Good luck
This post has been edited by debjit625: 27 August 2009 - 10:56 AM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|