登录
首页 » C#源码 » C# 打印XPS文档 XPS文件打印

C# 打印XPS文档 XPS文件打印

于 2022-03-23 发布 文件大小:132.40 kB
0 411
下载积分: 2 下载次数: 1

代码说明:

C# 打印选择的XPS文档,打印XPS文件,相关代码如下:   private void button1_Click(object sender, RoutedEventArgs e)   {//打印选择的XPS文档    var MyDlg = new Microsoft.Win32.OpenFileDialog();    MyDlg.InitialDirectory = System.IO.Directory.GetCurrentDirectory();    MyDlg.Filter = "XPS文件(*.xps)|*.xps|所有文件(*.*)|*.*";    if (MyDlg.ShowDialog() == true)    {    string MyFileName = MyDlg.FileName;    var pDialog = new PrintDialog();    pDialog.PageRangeSelection = PageRangeSelection.AllPages;    pDialog.UserPageRangeEnabled = true;    if (pDialog.ShowDialog() == true)    {    var MyDocument = new System.Windows.Xps.Packaging.XpsDocument(MyFileName, System.IO.FileAccess.ReadWrite);    FixedDocumentSequence MyFixedDocumentSequence = MyDocument.GetFixedDocumentSequence();    pDialog.PrintDocument(MyFixedDocumentSequence.DocumentPaginator, "我的XPS打印文档");    }    }   }

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • Visual C# 在无连接数据表中创建AutoIncrement列
    C# 在无连接数据表中创建AutoIncrement列,在数据表中添加记录一.代码:   //在数据表中添加记录一   DataRow MyRow = MyTable.NewRow();   MyRow["ID"] = 87121;   MyRow["Name"] = "罗斌";   MyRow["Tel"] = "023-40231026";   MyRow["MP"] = "13036371686";   MyRow["Company"] = "无锡宝特软件有限公司";   MyTable.Rows.Add(MyRow);   this.dataGridView1.DataSource = MyTable;
    2022-05-16 06:23:51下载
    积分:1
  • C# 使用几何图形剪辑图像控件中的部分区域
    C# 使用几何图形剪辑图像控件中的部分区域,类似于图片遮罩的效果,本例中,把一张图片裁切成椭圆形,图片显示在椭圆的底部,可随窗口的改变自动改变大校   private void Window_Loaded(object sender, RoutedEventArgs e)   {//使用几何图形剪辑图像控件中的部分区域    var MyClip = new EllipseGeometry();    MyClip.RadiusX = 120;    MyClip.RadiusY = 80;    MyClip.Center = new Point(145, 110);    this.image1.Clip = MyClip;   }
    2022-11-04 14:00:03下载
    积分:1
  • C# 利用“[^]”通配符进行查询
    C# 利用“[^]”通配符进行查询   string P_Str_ConnectionStr = string.Format(//创建数据库连接字符串    @"server=WIN-GI7E47AND9RLS;database=db_TomeTwo;uid=sa;pwd=");   string P_Str_SqlStr = string.Format(//创建SQL查询字符串    "SELECT 学生姓名,年龄,性别,家庭住址 FROM tb_Student");   SqlDataAdapter P_SqlDataAdapter = new SqlDataAdapter(//创建数据适配器    P_Str_SqlStr, P_Str_ConnectionStr);   DataTable P_dt = new DataTable();//创建数据表   P_SqlDataAdapter.Fill(P_dt);//填充数据表   return P_dt;//返回数据表
    2022-03-20 15:58:24下载
    积分:1
  • C# 创建一个泛型接口
    C# 创建一个泛型接口的例子,创建一个泛型接口的代码和方法如下:   public interface IGenericInterface   {    T CreateInstance(); //接口中调用CreateInstance方法   }   //实现上面泛型接口的泛型类   //派生约束where T : TI(T要继承自TI)   //构造函数约束where T : new()(T可以实例化)   public class Factory : IGenericInterface where T : TI, new()   {    public TI CreateInstance()//创建一个公共方法CreateInstance    {    return new T();    }   }   class Program   {    static void Main(string[] args)    {    //实例化接口    IGenericInterface factory =   Factory();    //输出指定泛型的类型    Console.WriteLine(factory.CreateInstance().GetType().ToString());    Console.ReadLine();    }   }
    2022-03-11 00:59:39下载
    积分:1
  • C#合成图片 组合文字及图像的实例
    C# 将多个文字图形图像组合成复合图形,一个组合文字及图像的实例。基于WPF技术实现,可作为一个C#学习WPF图像处理的简单范例。C# 将多个文字图形图像组合成复合图形:   DrawingGroup MyGroup = new DrawingGroup();   RadialGradientBrush MyRadialGradientBrush = new RadialGradientBrush();   MyRadialGradientBrush.Freeze();   FontStyle MyStyle = FontStyles.Normal;   FontWeight MyWeight = FontWeights.Medium;   MyWeight = FontWeights.Bold;   MyStyle = FontStyles.Italic;   string MyText = "Visual C++ 2017源码素材网实例精粹罗斌编著";   var MyFont = new FontFamily("宋体");   FormattedText MyFormattedText = new FormattedText(MyText,    System.Globalization.CultureInfo.GetCultureInfo(86),    FlowDirection.RightToLeft,    new Typeface(MyFont, MyStyle, MyWeight, FontStretches.Normal),    FontSize, MyRadialGradientBrush);   Pen MyPen = new Pen(Brushes.Black, 2);   MyPen.Freeze();   ……   更多源代码敬请下载本源码。运行截图如下图所示。
    2022-06-30 08:36:55下载
    积分:1
  • C# ScanPort 局域网端口扫描程序
    C#端口扫描程序,适用于局域网计算机的扫描,扫描时将遍历局域网中的工作组,并将计算机名显示在下拉列表控件中,用户可指定某电脑的端口扫描范围。判断工作组名称,遍历指定工作组中的所有计算机名称,并显示在ListBox控件中:   //实例化DirectoryEntry对象,以便获得局域网组名和计算机名   DirectoryEntry DEMain = new DirectoryEntry("WinNT:");   TcpClient TClient = null;//实例化连接侦听对象   private Thread myThread; //实例化线程对象   string strName = ""; //记录选择的计算机名称   int intflag = 0; //扫描到的端口号   int intport = 0; //记录已用端口号   int intstart = 0; //扫描的开始端口号   int intend = 0; //扫描的结束端口号   详细情况请下载源码。
    2023-05-16 16:35:03下载
    积分:1
  • C# 编写多种窗口排列方式的MDIForm窗体
    C# 实现MDIForm窗体功能,代码中实现了3个MDI子窗口,并以水平平铺、垂直平铺、层叠排列的方式实现多种子窗口的排列布局,其主要代码在form1.cs中,其它文件为生成子窗口的文件,关键代码如下:   private void toolStripMenuItem1_Click(object sender, EventArgs e)   {    Form2 frm2 = new Form2();//实例化Form2    frm2.MdiParent = this;//设置MdiParent属性,将当前窗体作为父窗体    frm2.Show();//使用Show方法打开窗体    Form3 frm3 = new Form3();//实例化Form3    frm3.MdiParent = this;//设置MdiParent属性,将当前窗体作为父窗体    frm3.Show();//使用Show方法打开窗体    Form4 frm4 = new Form4();//实例化Form4    frm4.MdiParent = this;//设置MdiParent属性,将当前窗体作为父窗体    frm4.Show();//使用Show方法打开窗体   }   private void 水平平铺ToolStripMenuItem_Click(object sender, EventArgs e)   {    LayoutMdi(MdiLayout.TileHorizontal);//使用MdiLayout枚举实现水平平铺   }   private void 垂直平铺ToolStripMenuItem_Click(object sender, EventArgs e)   {    LayoutMdi(MdiLayout.TileVertical);//使用MdiLayout枚举实现垂直平铺   }   private void 层叠排列ToolStripMenuItem_Click(object sender, EventArgs e)   {    LayoutMdi(MdiLayout.Cascade);//使用MdiLayout枚举实现层叠排列   }
    2022-03-07 15:00:14下载
    积分:1
  • Zigbee智能家居完整的
    Zigbee智能家居完整的源代码,含有终端和协调器工程并带有汉语注释。非常适合Zigbee开发。-Zigbee Smart Home complete source code, containing the terminal and the coordinator works with Chinese comments. Very suitable for the Zigbee development.
    2022-03-05 18:50:08下载
    积分:1
  • C# 写入并读取内存流
    C# 写入并读取内存流,演示一些基本的内存流操作方法,编写以下代码可实现这些功能:   byte[] BContent = Encoding.Default.GetBytes(textBox1.Text);   MemoryStream MStream = new MemoryStream(100);   MStream.Write(BContent, 0, BContent.Length);   richTextBox1.Text = "分配给该流的字节数:" + MStream.Capacity.ToString() + " 流长度:"    + MStream.Length.ToString() + " 流的当前位置:" + MStream.Position.ToString();   MStream.Seek(0, SeekOrigin.Begin);   byte[] byteArray = new byte[MStream.Length];   int count = MStream.Read(byteArray,0,(int)MStream.Length-1);   while (count < MStream.Length)   {    byteArray[count++] = Convert.ToByte(MStream.ReadByte());   }   char[] charArray = new char[Encoding.Default.GetCharCount(byteArray, 0, count)];   Encoding.Default.GetChars(byteArray, 0, count, charArray, 0);   for (int i = 0; i < charArray.Length; i++)   {    richTextBox2.Text += charArray[i].ToString();   }
    2022-03-11 09:55:00下载
    积分:1
  • C# 用于视频播放器的TimeLine时间线
    C# 用于视频播放器的TimeLine时间线源码,时间线预览效果可运行文件在VideoEditor文件夹的Bin目录下,不过需要.NET Framework 4.7版本以上,源码资源文件,包括了图片资源,代码资源都齐全,在VS2016或更高版本下运行。   本例用时间线来演示播放进度,类似进度条的功能。
    2022-12-02 17:55:03下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载