Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,038

HOME > ASP > ASP Forum > อยากทราบวิธีสร้าง Barcode โดยใช้ภาษา ASP ครับ


 

[ASP] อยากทราบวิธีสร้าง Barcode โดยใช้ภาษา ASP ครับ

 
Topic : 067296



โพสกระทู้ ( 61 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook Blogger


อยากทราบวิธีทำ barcode ครับ โดยเว็บไซต์ผมเป็น ASP คือต้องการปริ้นใบแจ้งหนี้ ผ่านทางระบบออนไลน์ครับ รบกวนช่วยแนะนำด้วยครับ



Tag : ASP

Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-09-28 13:54:55 By : karn4851 View : 2885 Reply : 4
 

 

No. 1



โพสกระทู้ ( 74,059 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

แนะนำทำเป็น PDF ไฟล์ครับ โดยใช้ Font Barcode ก็ได้แล้วครับ ไม่ยาก
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-28 14:06:35 By : webmaster
 

 

No. 2



โพสกระทู้ ( 61 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook Blogger

ถ้าใช้ font barcode แล้วสามารถนำไปใช้กับเครื่องสแกนบาร์โค้ดได้รึเปล่าครับ


ประวัติการแก้ไข
2011-09-28 15:44:16
2011-09-28 15:45:05
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-28 14:12:36 By : karn4851
 

 

No. 3



โพสกระทู้ ( 74,059 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

แน่นอนครับถ้าคุณ Print ลงกระดาษก็อ่านได้ปกติครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-28 20:50:22 By : webmaster
 

 

No. 4



โพสกระทู้ ( 8 )
บทความ ( 0 )



สถานะออฟไลน์


Introduction

In one of my projects, I needed to implement barcodes into an ASP.NET page. Unfortunately, the only way that I found was using a third party component. So, I decided to find a way to do it without using external components.

Using the code

First, you have to download a free barcode font. For this example, I used "IDAutomationHC39M" from IdAutomation. In this example, I used Barcode 39.

In WinForms applications, it is really easy to use Barcode fonts; just place a Label, and apply the free barcode font, and assign a value, and everything is ready.

In Webforms, things are different, because the application runs on the server. The barcode font must reside on the server. If we use a Label, the barcode font is located on the server, not on the client, so you will just see the value, not the barcode.

Well, let's start:

Just copy the barcode font into the windows\fonts folder of the server. The whole idea is to create a text with the font (a barcode), then create an image of it, and send it back to the client.

Here is a simple page with it:
'===========================================================================================

Code (C#)
001.using System;
002.using System.Collections;
003.using System.ComponentModel;
004.using System.Data;
005.using System.Drawing;
006.using System.Drawing.Imaging;
007.using System.Web;
008.using System.Web.SessionState;
009.using System.Web.UI;
010.using System.Web.UI.WebControls;
011.using System.Web.UI.HtmlControls;
012. 
013.namespace Barcodes
014.{
015. 
016./// <summary />
017./// Summary description for BarCode.
018./// </summary />
019. 
020.public class BarCode : System.Web.UI.Page
021.{
022.    private void Page_Load(object sender, System.EventArgs e)
023.    {
024.         // Get the Requested code to be created.
025.         string Code = Request["code"].ToString();
026. 
027.         // Multiply the lenght of the code by 40 (just to have enough width)
028.         int w = Code.Length * 40;
029.     
030.        // Create a bitmap object of the width that we calculated and height of 100
031.         Bitmap oBitmap = new Bitmap(w,100);
032.     
033.        // then create a Graphic object for the bitmap we just created.
034.         Graphics oGraphics = Graphics.FromImage(oBitmap);
035.         
036.        // Now create a Font object for the Barcode Font
037.        // (in this case the IDAutomationHC39M) of 18 point size
038.        Font oFont = new Font("IDAutomationHC39M", 18);
039.         
040.        // Let's create the Point and Brushes for the barcode
041.        PointF oPoint = new PointF(2f, 2f);
042.         SolidBrush oBrushWrite = new SolidBrush(Color.Black);
043.         SolidBrush oBrush = new SolidBrush(Color.White);
044.             
045.        // Now lets create the actual barcode image
046.        // with a rectangle filled with white color
047.        oGraphics.FillRectangle(oBrush, 0, 0, w, 100);
048.             
049.        // We have to put prefix and sufix of an asterisk (*),
050.        // in order to be a valid barcode
051.        oGraphics.DrawString("*" + Code + "*", oFont, oBrushWrite, oPoint);
052.         
053.        // Then we send the Graphics with the actual barcode
054.        Response.ContentType = "image/jpeg" ;
055.         oBitmap.Save (Response.OutputStream, ImageFormat.Jpeg);
056.    }
057.}
058.}
059. 
060.'===============================================================
061. 
062.As you can see, there is a barcode with the value of 1234.
063. 
064.Now, let’s create a page that has an asp:Image on it:
065.'==============================================================
066.<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
067.   AutoEventWireup="false" Inherits="BarCodes.WebForm1" %>
068.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
069.<HTML>
070. <HEAD>
071.  <title>WebForm1</title>
072.  <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
073.  <meta name="CODE_LANGUAGE" Content="C#">
074.  <meta name="vs_defaultClientScript" content="JavaScript">
075.  <meta name="vs_targetSchema"
076.        content="http://schemas.microsoft.com/intellisense/ie5">
077. </HEAD>
078. <body MS_POSITIONING="GridLayout">
079.  <form id="Form1" method="post" runat="server">
080.   <asp:Image id="myBarCode"  runat="server"></asp:Image>
081.  </form>
082. </body>
083.'===========================================================
084.using System;
085.using System.Collections;
086.using System.ComponentModel;
087.using System.Data;
088.using System.Drawing;
089.using System.Web;
090.using System.Web.SessionState;
091.using System.Web.UI;
092.using System.Web.UI.WebControls;
093.using System.Web.UI.HtmlControls;
094. 
095.namespace BarCodes
096.{
097.    /// <summary />
098.    /// Summary description for WebForm1.
099.    /// </summary />
100.    public class WebForm1 : System.Web.UI.Page
101.    {
102.        protected System.Web.UI.WebControls.Image myBarCode;
103.     
104.        private void Page_Load(object sender, System.EventArgs e)
105.        {
106.            // Put user code to initialize the page here
107.            myBarCode.ImageUrl = "BarCode.aspx?code=31231";
108.        }
109. 
110.        #region Web Form Designer generated code
111.        override protected void OnInit(EventArgs e)
112.        {
113.            //
114.            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
115.            //
116.            InitializeComponent();
117.            base.OnInit(e);
118.        }
119.         
120.        /// <summary />
121.        /// Required method for Designer support - do not modify
122.        /// the contents of this method with the code editor.
123.        /// </summary />
124.        private void InitializeComponent()
125.        {   
126.            this.Load += new System.EventHandler(this.Page_Load);
127. 
128.        }
129.        #endregion
130.    }
131.}

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-29 10:05:46 By : pathavong
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : อยากทราบวิธีสร้าง Barcode โดยใช้ภาษา ASP ครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่