Solved

Creating an image containing the text of a richTextBox

Posted on 2004-10-20
7
238 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why, and when, to use Windows Workflow 1 31
Get String split 5 46
Calling stored proc in EDMX 11 23
Problem to error 4 43
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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

21 Experts available now in Live!

Get 1:1 Help Now