Solved

Creating an image containing the text of a richTextBox

Posted on 2004-10-20
7
246 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

749 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