Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Creating an image containing the text of a richTextBox

Posted on 2004-10-20
7
Medium Priority
?
256 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

719 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