TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Manoj Mandal
1.3k
457
19.1k
barcode font not woking in iis
Jan 9 2020 11:54 PM
while running in my system barcode font is working but when i host the same in localhost iis barcode font is not working.
i have pasted the font in windows/fonts folder
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
public partial class barcode_generator : System.Web.UI.Page
{
protected void btnGenerate_Click(object sender, EventArgs e)
{
string barCode = txtCode.Text;
System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
using (Bitmap bitMap = new Bitmap(barCode.Length * 40, 80))
{
using (Graphics graphics = Graphics.FromImage(bitMap))
{
Font oFont = new Font("IDAutomationHC39M", 14);
PointF point = new PointF(2f, 2f);
SolidBrush blackBrush = new SolidBrush(Color.Black);
SolidBrush whiteBrush = new SolidBrush(Color.White);
graphics.FillRectangle(whiteBrush, 0, 0, bitMap.Width, bitMap.Height);
graphics.DrawString("*" + barCode + "*", oFont, blackBrush, point);
}
using (MemoryStream ms = new MemoryStream())
{
bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte[] byteImage = ms.ToArray();
Convert.ToBase64String(byteImage);
string result = Convert.ToBase64String(byteImage);
CreateImage(result.ToString());
imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
}
plBarCode.Controls.Add(imgBarCode);
}
}
public string CreateImage(string Byt)
{
try
{
// string path = Server.MapPath("files//" + file_name);
//FileInfo file = new FileInfo(path);
string path = Server.MapPath("~/images/barcode.jpg");
FileInfo file1 = new FileInfo(path);
if (file1.Exists)//check file exsit or not
{
file1.Delete();
}
byte[] data = Convert.FromBase64String(Byt);
var filename = "barcode.jpg";// +System.DateTime.Now.ToString("fffffffffff") + ".png";
var file = HttpContext.Current.Server.MapPath("~/images/" + filename);
System.IO.File.WriteAllBytes(file, data);
string ImgName = ".../images/" + filename;
return filename;
}
catch (Exception e)
{
return "Error";
}
}
}
Reply
Answers (
1
)
Convert enum type to string type when deserialize an xml
How could I check if those records exists in SQL ?