如何使用asp.net为项目和打印生成条形码 [英] How to Generate a Bar Code for Items and Print using asp.net

查看:117
本文介绍了如何使用asp.net为项目和打印生成条形码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用asp.net为项目创建条形码,我需要在Sql Server中保存条形码值。



我想要显示网格视图中生成的条形码项列表。



使用Citizen打印机打印条形码。



请提供任何解决方案.... ....

解决方案

请参阅以下链接



C#条码生成器WebService



代码是简单而直接的前进。 
它允许您打印条形码并从asp.net访问Citizen打印机。

1.在.net上安装免费字体3 of 9 Barcode
2.创建一个Asp.net项目
3.添加此代码


public void Submit_Click(object sender,EventArgs e)
{
try
{
PrintDocument pd = new PrintDocument();
pd.PrintPage + = new PrintPageEventHandler(pd_PrintPage);
//设置打印机名称。
//pd.PrinterSettings.PrinterName =file:// ns5 / hpoffice
//pd.PrinterSettings.PrinterName =Zebra New GK420t
pd.Print();
}
catch(exception ex)
{
Response.Write(Error:+ ex.ToString());
}
}
void pd_PrintPage(object sender,PrintPageEventArgs ev)
{
Font printFont = new Font(3 of 9 Barcode,17);
Font printFont1 = new Font(Times New Roman, 9,FontStyle.Bold);

SolidBrush br = new SolidBrush(Color.Black);

ev.Graphics.DrawString(* texttodisplay *,printFont,br, 10,65);
ev.Graphics.DrawString(* texttodisplay *,printFont1,br,10,85);

}


您好



请参阅以下链接。如果结算,请将其作为答案您的查询 。



http://forums.asp.net/t/ 1842839.aspx [ ^ ]



使用c#软件关注Asp.net中的条形码生成 [ ^ ]



http://stackoverflow.com/questions/7810784/how-to-generate-and-print-barcodes-in-web-application-in-c-sharp-asp-net [ ^ ]

关于解决方案#1 ...恕我直言...... 不要使用字体!!!,请不使用它们,避免许多未来的麻烦。为什么?因为如果您的条形码需要暴露于条形码验证过程,那么您的第一次拍摄肯定无法通过,如果您使用字体生成&打印条形码。字体不适合真正的条形码场景。 (正如我的经验所说)



相反,请使用此处列出的许多开源或商业解决方案 Vb.net 2008中条形码的实现 [ ^ ]



至于打印从ASP.NET生成的条形码...好吧,如果只使用传统的javascript windows.print()方法(只是google那个术语可以得到很多条目),你可能会有一些运气。如果您愿意,请向我详细介绍此主题,但至少提供打印机型号。



HTH


I need to Create a Bar Code for items using asp.net, I need to save the Bar Code Value in Sql Server.

I Want to Show the Generated Bar Code item List in Grid View.

Using Citizen Printer to the Print Bar Codes.

Please Provide me any Solution........

解决方案

See the following links

C# Barcode Generator WebService

Code is simple and strait forward.
It allows you to print barcode  and also access Citizen  printer from asp.net.
 
1.       Install font which is free on .net "3 of 9 Barcode"
2.       Create an Asp.net project
3.        Add this code
 
 
public void Submit_Click(object sender, EventArgs e)
        {
            try
            {
                PrintDocument pd = new PrintDocument();
                pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
                // Set the printer name. 
                //pd.PrinterSettings.PrinterName = "file://ns5/hpoffice
                //pd.PrinterSettings.PrinterName = "Zebra New GK420t"               
                pd.Print();
            }
            catch (Exception ex)
            {
                Response.Write("Error: " + ex.ToString());
            }
        }
        void pd_PrintPage(object sender, PrintPageEventArgs ev)
        {
            Font printFont = new Font("3 of 9 Barcode", 17);
            Font printFont1 = new Font("Times New Roman", 9, FontStyle.Bold);

            SolidBrush br = new SolidBrush(Color.Black);

            ev.Graphics.DrawString("*texttodisplay*", printFont, br, 10, 65);
            ev.Graphics.DrawString("*texttodisplay*", printFont1, br, 10, 85);
           
        }


Hi

Refer the below links . Marj it as answer if it resolves your query .

http://forums.asp.net/t/1842839.aspx[^]

Regards Bar Code generation in Asp.net using c# Software[^]

http://stackoverflow.com/questions/7810784/how-to-generate-and-print-barcodes-in-web-application-in-c-sharp-asp-net[^]


Regarding Solution #1... IMHO... Do not use fonts!!!, please Avoid many future headaches by not using them. Why? because if your barcode needs to be exposed to a Barcode Verification Process then yours will not pass it the first shot for sure, if you used fonts to generate & print the barcodes. Fonts are not suitable for real barcode scenarios, period. (just what my experience says)

Instead, use many open source or commercial solutions available out there like listed here Implementation of Barcode In Vb.net 2008[^]

As for printing the barcodes you generate from ASP.NET... well, you might have some luck if using just the traditional javascript windows.print() approach (just google that term to get many entries). Ask me more on this subject if you want but provide the printer model at least.

HTH


这篇关于如何使用asp.net为项目和打印生成条形码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆