9 个解决方案
#1
其实它们是一样的,只不过打发票的报表不要画线以及客户端要定义好打印纸张。
#2
http://delhpi.ys168.com
发票类似于支票。
发票类似于支票。
#3
关键是这种票据打印因为它有自己的尺寸,不像平常打印报表时不用思考,会自动设置成为A4或是B5之类的纸张大小,那这种自定义的大小如何定义呢?难道也是通过打印机设置去定义吗?
#4
UP
#5
打印依靠PringDocument实现,至于纸张设置,由用户在第一次使用时指定(也可以中途更改),但程序必须保存用户的设定,否则每次启动程序时做一次设置太不方便,保存和读取设置的代码参考下面.
private void SavePrintSetting()
{
RegistryKey hKey = Registry.CurrentUser.CreateSubKey(@"Software\xxxx公司\打印设置\3.0");
RegistryKey subKey = hKey.CreateSubKey(this.GetType().GUID.ToString("B"));
subKey.SetValue("PaperName", this.m_PrintDoc.DefaultPageSettings.PaperSize.PaperName);
subKey.SetValue("PaperKind", this.m_PrintDoc.DefaultPageSettings.PaperSize.Kind);
subKey.SetValue("PaperWidth", this.m_PrintDoc.DefaultPageSettings.PaperSize.Width);
subKey.SetValue("PaperHeight", this.m_PrintDoc.DefaultPageSettings.PaperSize.Height);
subKey.SetValue("PaperTop", this.m_PrintDoc.DefaultPageSettings.Margins.Top);
subKey.SetValue("PaperBottom", this.m_PrintDoc.DefaultPageSettings.Margins.Bottom);
subKey.SetValue("PaperLeft", this.m_PrintDoc.DefaultPageSettings.Margins.Left);
subKey.SetValue("PaperRight", this.m_PrintDoc.DefaultPageSettings.Margins.Right);
subKey.SetValue("PrinterName", this.m_PrintDoc.PrinterSettings.PrinterName);
subKey.SetValue("Landscape", this.m_PrintDoc.DefaultPageSettings.Landscape ? 1 : 0, RegistryValueKind.DWord);
subKey.Close();
}
private void LoadPrintSetting()
{
RegistryKey hKey = null;
RegistryKey subKey = null;
bool printResult = false, paperResult = false;
try
{
hKey = Registry.CurrentUser.OpenSubKey(@"Software\xxxx公司\打印设置\3.0");
subKey = hKey.OpenSubKey(this.GetType().GUID.ToString("B"));
string pName = subKey.GetValue("PaperName").ToString();
System.Drawing.Printing.PaperKind pKind = (System.Drawing.Printing.PaperKind)System.Enum.Parse(typeof(System.Drawing.Printing.PaperKind),subKey.GetValue("PaperKind").ToString());
int pWidth = (int)subKey.GetValue("PaperWidth");
int pHeight = (int)subKey.GetValue("PaperHeight");
string printer = subKey.GetValue("PrinterName").ToString();
int landscape = (int)subKey.GetValue("Landscape", 0);
foreach (string p in PrinterSettings.InstalledPrinters)
{
if (p == printer)
{
this.m_PrintDoc.PrinterSettings.PrinterName = printer;
printResult = true;
break;
}
}
this.m_PrintDoc.DefaultPageSettings.Landscape = (landscape == 1);
foreach (PaperSize pSize in this.m_PrintDoc.PrinterSettings.PaperSizes)
{
if ((pSize.PaperName == pName) && (pSize.Kind == pKind) && (pSize.Width == pWidth) && (pSize.Height == pHeight))
{
this.m_PrintDoc.DefaultPageSettings.PaperSize = pSize;
paperResult = true;
break;
}
}
this.m_PrintDoc.DefaultPageSettings.Margins.Top = (int)subKey.GetValue("PaperTop");
this.m_PrintDoc.DefaultPageSettings.Margins.Bottom = (int)subKey.GetValue("PaperBottom");
this.m_PrintDoc.DefaultPageSettings.Margins.Left = (int)subKey.GetValue("PaperLeft");
this.m_PrintDoc.DefaultPageSettings.Margins.Right = (int)subKey.GetValue("PaperRight");
}
catch (Exception)
{
printResult = false;
}
finally
{
if (subKey != null)
subKey.Close();
if (hKey != null)
hKey.Close();
}
if ((!printResult) || (!paperResult))
{
this.SavePrintSetting();
}
}
private void SavePrintSetting()
{
RegistryKey hKey = Registry.CurrentUser.CreateSubKey(@"Software\xxxx公司\打印设置\3.0");
RegistryKey subKey = hKey.CreateSubKey(this.GetType().GUID.ToString("B"));
subKey.SetValue("PaperName", this.m_PrintDoc.DefaultPageSettings.PaperSize.PaperName);
subKey.SetValue("PaperKind", this.m_PrintDoc.DefaultPageSettings.PaperSize.Kind);
subKey.SetValue("PaperWidth", this.m_PrintDoc.DefaultPageSettings.PaperSize.Width);
subKey.SetValue("PaperHeight", this.m_PrintDoc.DefaultPageSettings.PaperSize.Height);
subKey.SetValue("PaperTop", this.m_PrintDoc.DefaultPageSettings.Margins.Top);
subKey.SetValue("PaperBottom", this.m_PrintDoc.DefaultPageSettings.Margins.Bottom);
subKey.SetValue("PaperLeft", this.m_PrintDoc.DefaultPageSettings.Margins.Left);
subKey.SetValue("PaperRight", this.m_PrintDoc.DefaultPageSettings.Margins.Right);
subKey.SetValue("PrinterName", this.m_PrintDoc.PrinterSettings.PrinterName);
subKey.SetValue("Landscape", this.m_PrintDoc.DefaultPageSettings.Landscape ? 1 : 0, RegistryValueKind.DWord);
subKey.Close();
}
private void LoadPrintSetting()
{
RegistryKey hKey = null;
RegistryKey subKey = null;
bool printResult = false, paperResult = false;
try
{
hKey = Registry.CurrentUser.OpenSubKey(@"Software\xxxx公司\打印设置\3.0");
subKey = hKey.OpenSubKey(this.GetType().GUID.ToString("B"));
string pName = subKey.GetValue("PaperName").ToString();
System.Drawing.Printing.PaperKind pKind = (System.Drawing.Printing.PaperKind)System.Enum.Parse(typeof(System.Drawing.Printing.PaperKind),subKey.GetValue("PaperKind").ToString());
int pWidth = (int)subKey.GetValue("PaperWidth");
int pHeight = (int)subKey.GetValue("PaperHeight");
string printer = subKey.GetValue("PrinterName").ToString();
int landscape = (int)subKey.GetValue("Landscape", 0);
foreach (string p in PrinterSettings.InstalledPrinters)
{
if (p == printer)
{
this.m_PrintDoc.PrinterSettings.PrinterName = printer;
printResult = true;
break;
}
}
this.m_PrintDoc.DefaultPageSettings.Landscape = (landscape == 1);
foreach (PaperSize pSize in this.m_PrintDoc.PrinterSettings.PaperSizes)
{
if ((pSize.PaperName == pName) && (pSize.Kind == pKind) && (pSize.Width == pWidth) && (pSize.Height == pHeight))
{
this.m_PrintDoc.DefaultPageSettings.PaperSize = pSize;
paperResult = true;
break;
}
}
this.m_PrintDoc.DefaultPageSettings.Margins.Top = (int)subKey.GetValue("PaperTop");
this.m_PrintDoc.DefaultPageSettings.Margins.Bottom = (int)subKey.GetValue("PaperBottom");
this.m_PrintDoc.DefaultPageSettings.Margins.Left = (int)subKey.GetValue("PaperLeft");
this.m_PrintDoc.DefaultPageSettings.Margins.Right = (int)subKey.GetValue("PaperRight");
}
catch (Exception)
{
printResult = false;
}
finally
{
if (subKey != null)
subKey.Close();
if (hKey != null)
hKey.Close();
}
if ((!printResult) || (!paperResult))
{
this.SavePrintSetting();
}
}
#6
发票,添空打印
数据量不大,但要精确定位
绘画函数会用吧,先将发票扫描到一个图片文件,加载该图片到图片框,然后用绘画函数将数据添到图片中.有原发票为背景可以精确的调试定位
预览时可加原发票为背景
真正打印,不用加载发票图片,将生成的数据图片直接打印就可以了
数据量不大,但要精确定位
绘画函数会用吧,先将发票扫描到一个图片文件,加载该图片到图片框,然后用绘画函数将数据添到图片中.有原发票为背景可以精确的调试定位
预览时可加原发票为背景
真正打印,不用加载发票图片,将生成的数据图片直接打印就可以了
#7
用自定义尺寸纸张打印了
这个报表支持:
http://www.kitesoft.cn
这个报表支持:
http://www.kitesoft.cn
#8
up
#9
打印控件wsReport4.6
#1
其实它们是一样的,只不过打发票的报表不要画线以及客户端要定义好打印纸张。
#2
http://delhpi.ys168.com
发票类似于支票。
发票类似于支票。
#3
关键是这种票据打印因为它有自己的尺寸,不像平常打印报表时不用思考,会自动设置成为A4或是B5之类的纸张大小,那这种自定义的大小如何定义呢?难道也是通过打印机设置去定义吗?
#4
UP
#5
打印依靠PringDocument实现,至于纸张设置,由用户在第一次使用时指定(也可以中途更改),但程序必须保存用户的设定,否则每次启动程序时做一次设置太不方便,保存和读取设置的代码参考下面.
private void SavePrintSetting()
{
RegistryKey hKey = Registry.CurrentUser.CreateSubKey(@"Software\xxxx公司\打印设置\3.0");
RegistryKey subKey = hKey.CreateSubKey(this.GetType().GUID.ToString("B"));
subKey.SetValue("PaperName", this.m_PrintDoc.DefaultPageSettings.PaperSize.PaperName);
subKey.SetValue("PaperKind", this.m_PrintDoc.DefaultPageSettings.PaperSize.Kind);
subKey.SetValue("PaperWidth", this.m_PrintDoc.DefaultPageSettings.PaperSize.Width);
subKey.SetValue("PaperHeight", this.m_PrintDoc.DefaultPageSettings.PaperSize.Height);
subKey.SetValue("PaperTop", this.m_PrintDoc.DefaultPageSettings.Margins.Top);
subKey.SetValue("PaperBottom", this.m_PrintDoc.DefaultPageSettings.Margins.Bottom);
subKey.SetValue("PaperLeft", this.m_PrintDoc.DefaultPageSettings.Margins.Left);
subKey.SetValue("PaperRight", this.m_PrintDoc.DefaultPageSettings.Margins.Right);
subKey.SetValue("PrinterName", this.m_PrintDoc.PrinterSettings.PrinterName);
subKey.SetValue("Landscape", this.m_PrintDoc.DefaultPageSettings.Landscape ? 1 : 0, RegistryValueKind.DWord);
subKey.Close();
}
private void LoadPrintSetting()
{
RegistryKey hKey = null;
RegistryKey subKey = null;
bool printResult = false, paperResult = false;
try
{
hKey = Registry.CurrentUser.OpenSubKey(@"Software\xxxx公司\打印设置\3.0");
subKey = hKey.OpenSubKey(this.GetType().GUID.ToString("B"));
string pName = subKey.GetValue("PaperName").ToString();
System.Drawing.Printing.PaperKind pKind = (System.Drawing.Printing.PaperKind)System.Enum.Parse(typeof(System.Drawing.Printing.PaperKind),subKey.GetValue("PaperKind").ToString());
int pWidth = (int)subKey.GetValue("PaperWidth");
int pHeight = (int)subKey.GetValue("PaperHeight");
string printer = subKey.GetValue("PrinterName").ToString();
int landscape = (int)subKey.GetValue("Landscape", 0);
foreach (string p in PrinterSettings.InstalledPrinters)
{
if (p == printer)
{
this.m_PrintDoc.PrinterSettings.PrinterName = printer;
printResult = true;
break;
}
}
this.m_PrintDoc.DefaultPageSettings.Landscape = (landscape == 1);
foreach (PaperSize pSize in this.m_PrintDoc.PrinterSettings.PaperSizes)
{
if ((pSize.PaperName == pName) && (pSize.Kind == pKind) && (pSize.Width == pWidth) && (pSize.Height == pHeight))
{
this.m_PrintDoc.DefaultPageSettings.PaperSize = pSize;
paperResult = true;
break;
}
}
this.m_PrintDoc.DefaultPageSettings.Margins.Top = (int)subKey.GetValue("PaperTop");
this.m_PrintDoc.DefaultPageSettings.Margins.Bottom = (int)subKey.GetValue("PaperBottom");
this.m_PrintDoc.DefaultPageSettings.Margins.Left = (int)subKey.GetValue("PaperLeft");
this.m_PrintDoc.DefaultPageSettings.Margins.Right = (int)subKey.GetValue("PaperRight");
}
catch (Exception)
{
printResult = false;
}
finally
{
if (subKey != null)
subKey.Close();
if (hKey != null)
hKey.Close();
}
if ((!printResult) || (!paperResult))
{
this.SavePrintSetting();
}
}
private void SavePrintSetting()
{
RegistryKey hKey = Registry.CurrentUser.CreateSubKey(@"Software\xxxx公司\打印设置\3.0");
RegistryKey subKey = hKey.CreateSubKey(this.GetType().GUID.ToString("B"));
subKey.SetValue("PaperName", this.m_PrintDoc.DefaultPageSettings.PaperSize.PaperName);
subKey.SetValue("PaperKind", this.m_PrintDoc.DefaultPageSettings.PaperSize.Kind);
subKey.SetValue("PaperWidth", this.m_PrintDoc.DefaultPageSettings.PaperSize.Width);
subKey.SetValue("PaperHeight", this.m_PrintDoc.DefaultPageSettings.PaperSize.Height);
subKey.SetValue("PaperTop", this.m_PrintDoc.DefaultPageSettings.Margins.Top);
subKey.SetValue("PaperBottom", this.m_PrintDoc.DefaultPageSettings.Margins.Bottom);
subKey.SetValue("PaperLeft", this.m_PrintDoc.DefaultPageSettings.Margins.Left);
subKey.SetValue("PaperRight", this.m_PrintDoc.DefaultPageSettings.Margins.Right);
subKey.SetValue("PrinterName", this.m_PrintDoc.PrinterSettings.PrinterName);
subKey.SetValue("Landscape", this.m_PrintDoc.DefaultPageSettings.Landscape ? 1 : 0, RegistryValueKind.DWord);
subKey.Close();
}
private void LoadPrintSetting()
{
RegistryKey hKey = null;
RegistryKey subKey = null;
bool printResult = false, paperResult = false;
try
{
hKey = Registry.CurrentUser.OpenSubKey(@"Software\xxxx公司\打印设置\3.0");
subKey = hKey.OpenSubKey(this.GetType().GUID.ToString("B"));
string pName = subKey.GetValue("PaperName").ToString();
System.Drawing.Printing.PaperKind pKind = (System.Drawing.Printing.PaperKind)System.Enum.Parse(typeof(System.Drawing.Printing.PaperKind),subKey.GetValue("PaperKind").ToString());
int pWidth = (int)subKey.GetValue("PaperWidth");
int pHeight = (int)subKey.GetValue("PaperHeight");
string printer = subKey.GetValue("PrinterName").ToString();
int landscape = (int)subKey.GetValue("Landscape", 0);
foreach (string p in PrinterSettings.InstalledPrinters)
{
if (p == printer)
{
this.m_PrintDoc.PrinterSettings.PrinterName = printer;
printResult = true;
break;
}
}
this.m_PrintDoc.DefaultPageSettings.Landscape = (landscape == 1);
foreach (PaperSize pSize in this.m_PrintDoc.PrinterSettings.PaperSizes)
{
if ((pSize.PaperName == pName) && (pSize.Kind == pKind) && (pSize.Width == pWidth) && (pSize.Height == pHeight))
{
this.m_PrintDoc.DefaultPageSettings.PaperSize = pSize;
paperResult = true;
break;
}
}
this.m_PrintDoc.DefaultPageSettings.Margins.Top = (int)subKey.GetValue("PaperTop");
this.m_PrintDoc.DefaultPageSettings.Margins.Bottom = (int)subKey.GetValue("PaperBottom");
this.m_PrintDoc.DefaultPageSettings.Margins.Left = (int)subKey.GetValue("PaperLeft");
this.m_PrintDoc.DefaultPageSettings.Margins.Right = (int)subKey.GetValue("PaperRight");
}
catch (Exception)
{
printResult = false;
}
finally
{
if (subKey != null)
subKey.Close();
if (hKey != null)
hKey.Close();
}
if ((!printResult) || (!paperResult))
{
this.SavePrintSetting();
}
}
#6
发票,添空打印
数据量不大,但要精确定位
绘画函数会用吧,先将发票扫描到一个图片文件,加载该图片到图片框,然后用绘画函数将数据添到图片中.有原发票为背景可以精确的调试定位
预览时可加原发票为背景
真正打印,不用加载发票图片,将生成的数据图片直接打印就可以了
数据量不大,但要精确定位
绘画函数会用吧,先将发票扫描到一个图片文件,加载该图片到图片框,然后用绘画函数将数据添到图片中.有原发票为背景可以精确的调试定位
预览时可加原发票为背景
真正打印,不用加载发票图片,将生成的数据图片直接打印就可以了
#7
用自定义尺寸纸张打印了
这个报表支持:
http://www.kitesoft.cn
这个报表支持:
http://www.kitesoft.cn
#8
up
#9
打印控件wsReport4.6