Solved

Creating an image containing the text of a richTextBox

Posted on 2004-10-20
7
235 Views
Last Modified: 2010-04-15
Hello Experts!
  In one of our applications, we need to create a new image which contains the text that the user types in a RichTextBox.
  The new image should be created such that the user should be able to specify the width and height of the image, and the text in the RichTextBox should wrap and fit within the image (nothing should go out of the image rectangle area as long as the area is good enough to hold all the text).
  Can someone please provide code for how this can be done?

Thanks,
...Shu

P.S.
  We don't need any fancy coloring etc.
  Just a simple image containing the text wrapped according to the image size.
0
Comment
Question by:snehanshu
  • 3
  • 2
7 Comments
 
LVL 18

Expert Comment

by:armoghan
ID: 12356524
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12356532
0
 
LVL 5

Author Comment

by:snehanshu
ID: 12356562
armoghan,
  I don't seem to find how to wrap text using the links you gave.
  Can you extract only the required code that lets me create a wrapped-text image from the text in the richTextBox?
Thanks,
...Shu
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 18

Expert Comment

by:armoghan
ID: 12356638
No Text wraping is not in them, it just has the size of image and the text in it .

Dont know any way of doing the text wraping till now. as it could be difficult.

Another workaround could be..  Might not suit your requirement.

place a richtextbox on a Form, all over it, with FormBorderStyle=none
and you place all the text on it and then display it as a Dialog, and then send the Alt + Print key to save the image in the ClipBoard, then you can get the image from there.
0
 
LVL 5

Author Comment

by:snehanshu
ID: 12356778
This is what I was looking for:

/////////////////
int width = 500;
int height = 500;                  

Bitmap img = new Bitmap(width, height,  System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(img);
SolidBrush fgBrush = new SolidBrush(Color.White);
                  
g.DrawString(richTextBox1.Text, new Font("Arial", 10), fgBrush, new Rectangle(new Point(5,5), new Size(490, 490)));
img.Save(@"C:\Test\myimg.bmp");
/////////////////

Simple enough... only that I had to search in the professional C# book.

...Shu
P.S.
  I'll request for this Q to be paq'd or deleted if there are no better suggestions.
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 12392507
Question PAQ'd
125 points refunded.

CetusMOD
Community Support Moderator
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now