主要代码如下,借助ServerTextControl 和MailMerge实现后台合并,然后在不预览的情况下直接打印:
- private DataSet dsAddresses;
- private MailMerge mailMerge1;
- private void button1_Click(object sender, RoutedEventArgs e)
- {
- dsAddresses = new DataSet();
- dsAddresses.ReadXml(AppDomain.CurrentDomain.BaseDirectory + "\\data.xml");
- ServerTextControl stc = new ServerTextControl();
- mailMerge1 = new MailMerge();
- mailMerge1.TextComponent = stc;
- mailMerge1.LoadTemplate(AppDomain.CurrentDomain.BaseDirectory + "\\Template.tx", FileFormat.InternalUnicodeFormat);
- mailMerge1.Merge(dsAddresses.Tables[0], true);
- mailMerge1.Print("Test", "Snagit 11", 1, true);
- }
复制代码
11046_Page_WPF.zip
(10.52 KB, 下载次数: 571)
|