问题描述
我正在使用C#与的WinForms。我想打印账单上纸卷。纸张的宽度是3英寸,但纸张的长度是动态的(其辊纸)。长度取决于有多少项目有在列表中。例如。在一个购买,如果有100个项目出售那么这将是相当长的辊子,而对于单个项目购买这将是小的长度。
当我打印报告,结束作业后,打印机弹出最后一页比我更需要。它送出纸张只要A4尺寸。我想打印所需的线路,然后停止打印。我用了一卷纸,而不是A4或A3和爱普生LQ-300 + II打印机。
要更具体地,印刷进行时,总是以页大小的单元。如果我设置页面为3英寸x 8英寸然后我总是最后一个打印输出是8英寸长的倍数。如果我有一个9英寸账单打印,我结束了一个16英寸的打印输出,浪费了7英寸的纸张。我怎样才能最后一页是唯一的,只要它需要打印?
下面是code:
私人无效printDoc_PrintPage(对象发件人,PrintPageEventArgs E)
{
字体printFont =新的字体(宋体,12);
诠释Y = 15;
e.Graphics.DrawString(线路,printFont,Brushes.Black,0,Y); Y = Y + 20;
e.Graphics.DrawString(线,printFont,Brushes.Black,0,Y); Y = Y + 25;
e.Graphics.DrawString(线,printFont,Brushes.Black,0,Y); Y = Y + 35;
e.Graphics.DrawString(线,printFont,Brushes.Black,0,Y); Y = Y + 45;
}
您是否尝试过使用一个网页,只是一条线长?
省略上下边框,并且可以打印不停。
现在增加一点(这样的页面可以撕下),退出。
试试这个:
PAPERSIZE pkCustomSize1 =新PAPERSIZE(第一个自定义大小,100,200);
printDoc.DefaultPageSettings.PaperSize = pkCustomSize1
请参阅:http://msdn.microsoft.com/en-us/library/system.drawing.printing.pagesettings.papersize.aspx
I am using C# with Winforms. I am trying to print bills on a paper roll. The width of the paper is 3in but the length of the paper is dynamic (its a roll paper). The length depends on how many items are there in the list. E.g. in a purchase if there are 100 items sold then it will be quite long roll while for a single item purchased it would be of small length.
When I print the report, after the end job, printer eject the last page more than I need. It eject paper as long as A4 size. I want to print the required lines, then stop printing.I use a roll of paper, not A4 or A3 and an Epson LQ-300 + II printer.
To be more specific, printing is always done to page-sized units. If I set the page to be 3in x 8in then I always end up with a printout that is a multiple of 8in long. If I have a 9in bill to print, I end up with a 16in printout, wasting 7in of paper. How can I print with the last page being only as long as it needs to be?
Here is the code:
private void printDoc_PrintPage(Object sender, PrintPageEventArgs e)
{
Font printFont = new Font("Courier New", 12);
int y = 15;
e.Graphics.DrawString("a Line", printFont, Brushes.Black, 0, y); y = y + 20;
e.Graphics.DrawString(" Line", printFont, Brushes.Black, 0, y); y = y + 25;
e.Graphics.DrawString(" Line", printFont, Brushes.Black, 0, y); y = y + 35;
e.Graphics.DrawString(" Line", printFont, Brushes.Black, 0, y); y = y + 45;
}
Have you tried using a page that is only "one line" long?
Omit the upper and lower border, and you can print non stop.
Now add a bit (So the page can be torn off) and eject that.
Try this:
PaperSize pkCustomSize1 = new PaperSize("First custom size", 100, 200);
printDoc.DefaultPageSettings.PaperSize = pkCustomSize1
See:http://msdn.microsoft.com/en-us/library/system.drawing.printing.pagesettings.papersize.aspx
这篇关于上打印卷纸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!