python处理xps文件_自学WPF--第二十四课XPS文件处理

XAML代码如下:

x:Class="DEMO_XPS文?件t处ä|理¤¨ª.MainWindow"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Title="MainWindow" Height="630"

Width="667">

HorizontalAlignment="Left" Margin="12,48,0,0"

Name="documentViewer1" VerticalAlignment="Top" Width="621"

/>

Height="23" HorizontalAlignment="Left" Margin="12,12,0,0"

Name="buttonLoad" VerticalAlignment="Top" Width="75"

/>

Content="打䨰印®?方¤?式º?一°?" Height="23" HorizontalAlignment="Left"

Margin="118,12,0,0" Name="buttonMode1" VerticalAlignment="Top"

Width="75" />

Content="打䨰印®?方¤?式º?二t" Height="23" HorizontalAlignment="Left"

Margin="230,12,0,0" Name="buttonMode2" VerticalAlignment="Top"

Width="75" />

后台功能代码如下:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

using System.Windows.Xps.Packaging;

using System.Printing;

namespace DEMO_XPS文?件t处ä|理¤¨ª

{

///

///

Interaction logic for MainWindow.xaml

///

public

partial class MainWindow : Window

{

public MainWindow()

{

InitializeComponent();

}

private

void buttonLoad_Click(object sender, RoutedEventArgs e)

{

//添加引用ReachFrameWork

//引入命名空间using System.Windows.Xps.Packaging;

XpsDocument document = new XpsDocument(@"Demo.xps",

System.IO.FileAccess.Read);

FixedDocumentSequence fds =

document.GetFixedDocumentSequence();

documentViewer1.Document = fds;

}

//导Ì?入¨?后¨®打䨰印®?

private void buttonMode1_Click(object sender, RoutedEventArgs

e)

{

PrintDialog pd = new PrintDialog();

pd.PageRangeSelection = PageRangeSelection.AllPages;

pd.UserPageRangeEnabled = true;

bool ? ok= pd.ShowDialog();

if (ok==true)

{

XpsDocument

document = new

XpsDocument(@"Demo.xps",System.IO.FileAccess.Read);

FixedDocumentSequence fds=document.GetFixedDocumentSequence();

pd.PrintDocument(fds.DocumentPaginator, "demo");

}

}

private void buttonMode2_Click(object sender, RoutedEventArgs

e)

{

//添加引用System.Printing

//引入命名空间using System.Printing;

LocalPrintServer lps = new LocalPrintServer();

PrintQueue pq = lps.DefaultPrintQueue;

pq.AddJob("demo", @"Demo.xps", false);

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值