设计为WPF或WinForms Applicaton打印ID卡 [英] Designing to print ID card for WPF or WinForms Applicaton
本文介绍了设计为WPF或WinForms Applicaton打印ID卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以帮我解决如何在WPF中设计身份证的问题。
我希望所有的数据能够在没有数据库的情况下从文本块中提取图片。
只需按下品脱按钮,即可打印卡片。任何人都可以给我一些提示。
如果你有源代码请给我。
Can anyone help me out how to go about designing a ID card in WPF.
I want all the data to be together wit the picture to be pulled out from the Text-block without Data Base.
Just hit the pint button and card will be printed. can anyone give me some hints.
If you have source code please give it to me.
推荐答案
由于我对Windows Forms更熟悉,我会选择这条路径,除非有要求使用WPF。
创建一个表格,其中包含您需要的TextBox
,添加ID照片的PictureBox
并添加 PrintPreviewControl [ ^ ]到表单。
每次玩具更改任何数据或图片,你调用方法printPreviewControl.InvalidatePreview()
。
你还需要一个PrintDocument [ ^ ]您连接到PrintPreviewControl
。
实现事件PrintDocument.PrintPage并在此处完成所有绘图。
小例子:(你在MSDN上有更好的例子)
As I am more familiar with Windows Forms I would chose that path, unless there is a requirement to use WPF.
Create a form with the number ofTextBox
you need, add aPictureBox
for the ID photo and add a PrintPreviewControl[^] to the form.
Every time toy change any data or the picture, you call the methodprintPreviewControl.InvalidatePreview()
.
You also need a PrintDocument[^] that you connect to thePrintPreviewControl
.
Implement the event PrintDocument.PrintPage and do all drawing here.
Small example: (You have better examples at MSDN)
private void printDocument_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics g = e.Graphics;
if (pictureBox.Image != null)
g.DrawImage(pictureBox.Image, 0, 0, 200, 200);
g.DrawString("Hello World", new Font("Arial", 10.0F),
new SolidBrush(Color.Blue), 10, 250);
}
请注意,单位是100英寸。 (4= 400个单位)
这样你可以将所有内容打印到预览控件而不是浪费纸张。
如果要将数据发送到打印机,请调用方法 PrintDocument.Print()
。
这篇关于设计为WPF或WinForms Applicaton打印ID卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文