通过C#编程使用点阵打印机进行打印
我使用 此网站 上的 Microsoft 代码模板以及此代码片段仅打印一行和换页:
string s = "Hello world!\xC"; //\xC means form feed
PrintDialog pd = new PrintDialog();
pd.PrinterSettings = new PrinterSettings();
if (DialogResult.OK == pd.ShowDialog(this))
{
RawPrinterHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName, s);
}
但不幸的是,我的纸张尺寸长总是像 A4 纸张尺寸长。
我的代码有什么问题吗?有人有解决这个问题的提示或技巧吗?
I am using the code template from Microsoft at this site with this snippet to print out only a single line and form feed:
string s = "Hello world!\xC"; //\xC means form feed
PrintDialog pd = new PrintDialog();
pd.PrinterSettings = new PrinterSettings();
if (DialogResult.OK == pd.ShowDialog(this))
{
RawPrinterHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName, s);
}
But no luck, my paper size long is always like A4 paper size long.
What is wrong with my code? Do anyone got a hint or trick to deal with this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很难说问题可能是什么。
SendStringToPrinter
最终调用WritePrinter
,它应该将您发送到打印机的内容原样复制。换页应该将纸张垂直推进到下一页的开头。在这种情况下,“下一页”是由打印机定义的,打印机的配置将说明一页的长度。您是否只想使用换行符前进一行?
It's hard to say what the problem might be.
SendStringToPrinter
ultimately ends up callingWritePrinter
, which is supposed to copy what you send it to the printer unchanged. A form feed is supposed to advance the paper vertically to the beginning of the next page. "Next page" in this case is defined by the printer, and the printer's configuration will say how long a page is.Are you perhaps wanting to advance just one line by using a line feed?