提高C#中的打印区域质量 [英] Improve the quality of printing area in C#
本文介绍了提高C#中的打印区域质量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在C#Windows应用程序的面板控件中打印数据.
我正在使用以下代码来获取打印区域:
Hi,
I want to print the data in a panel control in C# windows application.
I''m using the following code to get the printing area:
Bitmap MemoryImage;
public void GetPrintArea(Panel pnl)
{
MemoryImage = new Bitmap(pnl.Width, pnl.Height);
Rectangle rect = new Rectangle(0, 0, pnl.Width, pnl.Height);
//MemoryImage.SetResolution(100f, 100f);
pnl.DrawToBitmap(MemoryImage, new Rectangle(0, 0, pnl.Width, pnl.Height));
}
void printDoc1_PrintPage(object sender, PrintPageEventArgs e)
{
Rectangle pagearea = e.PageBounds;
e.Graphics.DrawImage(MemoryImage, 0, 0);
//MemoryImage.SetResolution(200f, 200f);
}
但是在打印时,文档质量很差,标签和图像在打印时不清晰.如何获得清晰的印刷品?
谢谢.
But when printing, the quality of document is very poor, labels and images are not clear on print. How can I get the clear print?
Thank you.
推荐答案
添加此命名空间
使用System.Drawing.Printing;
使用System.IO;
类标签变量
add this namespace
using System.Drawing.Printing;
using System.IO;
class label variable
System.Drawing.Bitmap memoryimage;
write this code printbutton_click event
PrintDialog myprintdialog = new PrintDialog();
memoryimage = new System.Drawing.Bitmap(panelprint.Width, panelprint.Height);
panelprint.DrawToBitmap(memoryimage, panelprint.ClientRectangle);
if (myprintdialog.ShowDialog() == DialogResult.OK)
{
System.Drawing.Printing.PrinterSettings value;
value = myprintdialog.PrinterSettings;
myprintdialog.Document = printDocument1;
printDocument1.PrintController = new StandardPrintController();
panelprint.BackColor = Color.White;
printDocument1.Print();
}
<pre lang="cs">private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(memoryimage, -2, 30);
}</pre>
其中panelprint是面板的名称
我认为这对您有帮助........
问候
假:)
where panelprint is the name of panel
I think this is helpfull to u..........
Regard
Sham :)
浏览以下链接,这可能会对您有所帮助.
在这里 [此处 [
Hi,
Go through the below links, this may helps you.
Hwere[^]
Here[^]
Thanks
--RA
这篇关于提高C#中的打印区域质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文