如何在打印时设置页面副本 [英] How to set a page copies when you going to print
本文介绍了如何在打印时设置页面副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我手动创建了一个打印机命令。我打印时使用了richtextbox来显示文本然后选择组合框来选择或选择可用的打印机和一个打印按钮。
我用过这个代码:
I created a printer command manually. I've used a richtextbox to have a text when I print then combobox for choosing or selecting a printers available and a button to print.
I've used this codes:
private void button1_Click(object sender, EventArgs e)
{
PrintDocument1.PrinterSettings.PrinterName = cbox.SelectedItem.ToString();
PrintDocument1.Print();
}
private void frmMain_Load(object sender, EventArgs e)
{
foreach (String printer in PrinterSettings.InstalledPrinters)
{
cbox.Items.Add(printer.ToString());
}
}
现在问题是如何设置页面副本?例如,我的文本包含6页,然后我想打印3到6页,就像我们要打印文档时的Microsoft单词一样。我要添加什么工具以及要添加的代码?请帮我解决这个问题。谢谢
Now problem is how can I set the page copies ? For example my text contains of 6 pages then I want to print only 3 to 6 pages like in the Microsoft word when we going to print a document. What tool I'm gonna add and what codes to be add? Please help me to solve this problem. Thank you
推荐答案
参见 http://msdn.microsoft.com/en-us/library/system.drawing.printing.printersettings(v = vs.110).aspx [ ^ ],并使用适当的属性。
See http://msdn.microsoft.com/en-us/library/system.drawing.printing.printersettings(v=vs.110).aspx[^], and use the appropriate properties.
您需要执行以下操作:
You need to do something like the following:
private void PrintDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
checkPrint = rtbDoc.Print(checkPrint, rtbDoc.TextLength, e);
if (checkPrint < rtbDoc.TextLength)
{
e.HasMorePages = true;
}
else
{
e.HasMorePages = false;
}
// get the page settings object for this print session
PageSettings pgs = e.PageSettings;
// get the printer settings associated with this session
PrinterSettings prs = pgs.PrinterSettings;
// check that the current page number is within the range in the printer settings
if (pageNumber >= prs.FromPage && pageNumber <= prs.ToPage)
{
// print the page
}
}
这篇关于如何在打印时设置页面副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文