473,321 Members | 1,667 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Can anyone do this for me?????

i have a textbox in which i write in bangla(Bengali). but when i try to convert the bangla text into a GIF file the image shows ????? or something like a box. By the way i used AVRO Bangla typing software.

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Web;
  5. using System.Web.Security;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using System.Web.UI.WebControls.WebParts;
  9. using System.Web.UI.HtmlControls;
  10. using System.Text;
  11. using System.Drawing;
  12. using System.Drawing.Imaging;
  13. using System.Drawing.Text;
  14. using System.Drawing.Drawing2D;
  15.  
  16.  
  17.  
  18. public partial class _Default : System.Web.UI.Page 
  19. {
  20.     protected void Page_Load(object sender, EventArgs e)
  21.     {
  22.  
  23.     }
  24.  
  25.  
  26.     protected void TextBox4_TextChanged1(object sender, EventArgs e)
  27.     {
  28.         string s = TextBox4.Text;
  29.         System.Console.WriteLine(s);
  30.  
  31.     }
  32.     protected void Button4_Click(object sender, EventArgs e)
  33.     {
  34.         string infotext = null;
  35.         string text = TextBox4.Text;//Request.Form.Get("text");
  36.         int textLength = text.Length;
  37.         int fontSize = 14;
  38.         int orientation = 1;
  39.         int antialias = 1;
  40.         int width;
  41.         int height;
  42.  
  43.  
  44.         width = (fontSize * textLength) - ((textLength * fontSize) / 3);
  45.         height = fontSize + 20;
  46.  
  47.          infotext=text;
  48.  
  49.       //Byte[] sourceBytes = Encoding.GetEncoding("utf-8").GetBytes(infotext);
  50.       //Byte[] strbytes = Encoding.Convert(Encoding.GetEncoding(57003),Encoding.Unicode, sourceBytes);
  51.       //infotext = Encoding.Unicode.GetString(strbytes);
  52.       //text = infotext;
  53.  
  54.  
  55.  
  56.         // Initialize graphics
  57.         RectangleF rectF = new RectangleF(0, 0, width, height);
  58.         Bitmap pic = new Bitmap(width, height, PixelFormat.Format24bppRgb);
  59.         Graphics g = Graphics.FromImage(pic);
  60.         g.SmoothingMode = SmoothingMode.AntiAlias;
  61.  
  62.         g.TextRenderingHint = TextRenderingHint.AntiAlias;
  63.  
  64.  
  65.         // Set colors
  66.         string fgColor = "Black";
  67.         string bgColor = "White";
  68.         Color fontColor = Color.FromName(fgColor);
  69.         Color rectColor = Color.FromName(bgColor);
  70.         SolidBrush fgBrush = new SolidBrush(fontColor);
  71.         SolidBrush bgBrush = new SolidBrush(rectColor);
  72.  
  73.         // Rectangle 
  74.         int bound = 1;
  75.         g.FillRectangle(bgBrush, rectF);
  76.  
  77.         // Load font
  78.  
  79.         string fontName = "SUTOE___" + ".ttf";// this is bangla font file
  80.         PrivateFontCollection privateFontCollection = new PrivateFontCollection();
  81.         privateFontCollection.AddFontFile(Server.MapPath("./") + fontName);
  82.  
  83.         FontFamily fontFamily = privateFontCollection.Families[0];
  84.  
  85.         // Set font style
  86.         FontStyle style = FontStyle.Regular;
  87.         Font font = new Font(fontFamily, fontSize, style, GraphicsUnit.Pixel);
  88.  
  89.  
  90.         // Set font direction & alignment
  91.         StringFormat format = new StringFormat();
  92.  
  93.  
  94.         int alignment = 1;
  95.         if (alignment == 1)
  96.         {
  97.             format.Alignment = StringAlignment.Near;
  98.         }
  99.         format.LineAlignment = StringAlignment.Center;
  100.  
  101.  
  102.  
  103.  
  104.         // Finally, draw the font
  105.          g.DrawString(text, font, fgBrush, rectF, format);
  106.  
  107.  
  108. pic.Save(Server.MapPath("~/generated_image.gif"),ImageFormat.Gif);
  109.  
  110.  
  111.  
  112.  
  113.     }
  114.     protected void Button1_Click(object sender, EventArgs e)
  115.     {
  116.         string s = TextBox4.Text;
  117.         System.Console.WriteLine(s);
  118.     }
  119. }
Feb 28 '07 #1
2 1221
i have a textbox in which i write in bangla(Bengali). but when i try to convert the bangla text into a GIF file the image shows ????? or something like a box. By the way i used AVRO Bangla typing software.

Code:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.Drawing.Drawing2D;



public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}


protected void TextBox4_TextChanged1(object sender, EventArgs e)
{
string s = TextBox4.Text;
System.Console.WriteLine(s);

}
protected void Button4_Click(object sender, EventArgs e)
{
string infotext = null;
string text = TextBox4.Text;//Request.Form.Get("text");
int textLength = text.Length;
int fontSize = 14;
int orientation = 1;
int antialias = 1;
int width;
int height;


width = (fontSize * textLength) - ((textLength * fontSize) / 3);
height = fontSize + 20;

infotext=text;

//Byte[] sourceBytes = Encoding.GetEncoding("utf-8").GetBytes(infotext);
//Byte[] strbytes = Encoding.Convert(Encoding.GetEncoding(57003),Encod ing.Unicode, sourceBytes);
//infotext = Encoding.Unicode.GetString(strbytes);
//text = infotext;



// Initialize graphics
RectangleF rectF = new RectangleF(0, 0, width, height);
Bitmap pic = new Bitmap(width, height, PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(pic);
g.SmoothingMode = SmoothingMode.AntiAlias;

g.TextRenderingHint = TextRenderingHint.AntiAlias;


// Set colors
string fgColor = "Black";
string bgColor = "White";
Color fontColor = Color.FromName(fgColor);
Color rectColor = Color.FromName(bgColor);
SolidBrush fgBrush = new SolidBrush(fontColor);
SolidBrush bgBrush = new SolidBrush(rectColor);

// Rectangle
int bound = 1;
g.FillRectangle(bgBrush, rectF);

// Load font

string fontName = "SUTOE___" + ".ttf";// this is bangla font file
PrivateFontCollection privateFontCollection = new PrivateFontCollection();
privateFontCollection.AddFontFile(Server.MapPath(" ./") + fontName);

FontFamily fontFamily = privateFontCollection.Families[0];

// Set font style
FontStyle style = FontStyle.Regular;
Font font = new Font(fontFamily, fontSize, style, GraphicsUnit.Pixel);


// Set font direction & alignment
StringFormat format = new StringFormat();


int alignment = 1;
if (alignment == 1)
{
format.Alignment = StringAlignment.Near;
}
format.LineAlignment = StringAlignment.Center;




// Finally, draw the font
g.DrawString(text, font, fgBrush, rectF, format);


pic.Save(Server.MapPath("~/generated_image.gif"),ImageFormat.Gif);




}
protected void Button1_Click(object sender, EventArgs e)
{
string s = TextBox4.Text;
System.Console.WriteLine(s);
}
}
Mar 1 '07 #2
kenobewan
4,871 Expert 4TB
Here is an article that may help:
Creating Multilingual Websites - Part 3
Mar 1 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: asdf sdf | last post by:
i have an install issue with moinmoin on win2k. i've tried the mailing list, but it appears to be a very low traffic, low subscriber list. can i get a reality check? is anyone using moinmoin in...
1
by: Simon Harvey | last post by:
Hi chaps, Does anyone know if the beast is going to release Visual Tools for office to work with Visual Studio 2002 and not just 2003, or are they quite happy to shaft those that supported them...
1
by: Greg Steele | last post by:
Does anyone have a copy or know where I can get an installation executable for chiliReports 2.0 from chili! soft? The company I'm working for bought a copy several years ago, then moved their...
2
by: Ken Shaw | last post by:
G'day, I'm trying to tack down any delta compression library that I could licence for use in a project. Does anyone know of a decent binary delta compression library? cheers, Ken Shaw
0
by: james | last post by:
Hi guys! I´ve got a centerd table on my site with a black 1 pixel border. What i would like to do is to add a drop shadow to the table. Anyone know if it's possible to create a drop shadow for a...
162
by: Isaac Grover | last post by:
Hi everyone, Just out of curiosity I recently pointed one of my hand-typed pages at the W3 Validator, and my hand-typed code was just ripped to shreds. Then I pointed some major sites...
0
by: Jay1969 | last post by:
Hey all, I heard there was a new service offered to Microsoft partners called ISV Advisory Services (see link) where MS is giving free dev consulting to their Partners. ...
13
by: penguin732901 | last post by:
Checking back for discussions, there was a lot of talk about 2000 being slower than 97, but not so much lately. What is the latest opinion? Anyone care to set up a poll for how many NG members...
2
by: Brent Taylor via AccessMonster.com | last post by:
HELP----DOES ANYONE HAVE A SIMPLE .mdb for MLM structure? Does anyone have an example database for multi-level marketing for a 3 Tier setup? Thank you, brenttaylor@actionimports.net
2
by: Bruno Alexandre | last post by:
Hi guys, does anyone know where is the Website used in the MSDN "Lear ASP.NET 2.0 with Jeff Prosise" (http://msdn.microsoft.com/asp.net/beta2/multimedia/default.aspx) events? The website used...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.