Solved

Creating an image containing the text of a richTextBox

Posted on 2004-10-20
7
253 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Industry Leaders: 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!

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

623 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