解决方案 »
- 请问如何获得网页中flash游戏和后台交互的方式和地址
- udp如何将IList发送到客户端
- 数据库连接的问题????An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this fail
- windows应用程序 DataGrid 中的checkbox的问题?
- c#如何按行来读取文本文件,并显示文本的行数
- 还是哪个 字符的问题 换种方法问
- C#程序占用内存大????▲
- 关于启动窗体
- 关于treeview 的问题
- 警告:用金山毒霸2003可能导致vs.net help system工作异常!!!建议勿装金山毒霸2003!!!
- wpf关于弹出消息,请教
- winform在textbox中显示不断追加的字符串时发生异常,怎么解决?
1、客户端有装打印机驱动吧。
2、浏览器的权限设置了吗??如果安全设的高了,有可能会打印不出来。
3、打印机是安装在LPT1上的吗??有些打印机是USB接口的,还有的是网络打印机。
1、客户端有装的,打印测试页都是可以的
2、浏览器权限已设置为中了,2003的系统,中是最低的了
3、是LPT1端口上的,确定后来在程序代码里加了一个按钮,很一行代码下面加一个输出,看会不会卡在哪一步,结果12345全都输出了!!!
protected void Button1_Click(object sender, EventArgs e)
{
string sBarCodeCMD = ""; //条码打印命令
Response.Write("1");
StringBuilder sb1 = new StringBuilder(10240);
Response.Write("2");
int i1;
Response.Write("3");
i1 = GETFONTHEX("测试", "宋体", "temp1", 0, 30, 20, 0, 0, sb1);
Response.Write("4");
sBarCodeCMD = sb1.ToString() + "^XA^MD30^LH20,20^FO20,20^XGtemp1,1,1^FS^XZ";
Response.Write("5");
}
不借助ocx的web打印都是扯淡当然sl以及fl除外..所以可能你这个代码在CS可以运行 但是在BS下 肯定不行..
找找别的插件吧 比如那个叫什么楚林的 很不错 我在用
\
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;namespace Barcode
{
/*条码打印命令说明
^XA //条码打印指令开始
^MD30 //设置色带颜色的深度, 取值范围从-30到30
^LH60,10 //设置条码纸的边距
^FO20,10 //设置条码左上角的位置
^ACN,18,10 //设置字体
^BY1.4,3,50 //设置条码样式。1.4是条码的缩放级别,3是条码中粗细柱的比例, 50是条码高度
^BC,,Y,N //打印code128的指令
^FD12345678^FS //设置要打印的内容, ^FD是要打印的条码内容^FS表示换行
^XZ //条码打印指令结束
*/
//上面的指令会打印12345678的CODE128的条码
public class BarcodePrint
{
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
private struct OVERLAPPED
{
int Internal;
int InternalHigh;
int Offset;
int OffSetHigh;
int hEvent;
}
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
private static extern int CreateFile(
string lpFileName,
uint dwDesiredAccess,
int dwShareMode,
int lpSecurityAttributes,
int dwCreationDisposition,
int dwFlagsAndAttributes,
int hTemplateFile
);
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
private static extern bool WriteFile(
int hFile,
byte[] lpBuffer,
int nNumberOfBytesToWrite,
out int lpNumberOfBytesWritten,
out OVERLAPPED lpOverlapped
);
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
private static extern bool CloseHandle(int hObject);
private int iHandle;
public bool Open()
{
iHandle = CreateFile("LPT1:", (uint)FileAccess.ReadWrite, 0, 0, (int)FileMode.Open, 0, 0);
if (iHandle != -1)
{
return true;
}
else
{
return false;
}
}
public bool Write(string Mystring)
{
if (iHandle != -1)
{
int i;
OVERLAPPED x;
byte[] mybyte = System.Text.Encoding.Default.GetBytes(Mystring);
return WriteFile(iHandle, mybyte, mybyte.Length, out i, out x);
}
else
{
throw new Exception("LPT1端口未打开!");
}
}
public bool Close()
{
return CloseHandle(iHandle);
}
}
class Program
{
[System.Runtime.InteropServices.DllImport("fnthex32.dll")]
public static extern int GETFONTHEX(
string BarcodeText,
string FontName,
string FileName,
int Orient,
int Height,
int Width,
int IsBold,
int IsItalic,
StringBuilder ReturnBarcodeCMD
); public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
BarcodePrint print = new BarcodePrint();
// 打印数字和字母的条码
// 打印12345678的CODE128的条码
string sBarCodeCmdAsii = "^XA^MD30^LH60,10^FO20,10^ACN,18,10^BY1.4,3,50^BC,,Y,N^FD12345678^FS^XZ";
print.Write(sBarCodeCmdAsii); // 打印包含汉字的条码
// 打印汉字"测试"
string sBarCodeCMD = ""; //条码打印命令
StringBuilder sb1 = new StringBuilder(10240);
int i1;
i1 = GETFONTHEX("测试","宋体","temp1",0,30,20,0,0,sb1);
sBarCodeCMD = sb1.ToString() + "^XA^MD30^LH20,20^FO20,20^XGtemp1,1,1^FS^XZ";
print.Write(sBarCodeCMD);
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
ASPNET: 请确保此代码文件中定义的类与“inherits”属性匹配,并且该类扩展的基类(例如 Page 或 UserControl)是正确的。