将Xaml文档转成XPS文档

不用变压器也能联网?手把手教你PHY芯片直连的3种实用方案 本文详细介绍了PHY芯片直连的3种实用方案,帮助开发者在物联网设备中实现更经济、更精简的网络连接设计。通过分析电压驱动型和电流驱动型PHY的核心原理,提供具体的电路配置和优化建议,确保信号质量的同时节省成本和空间。 阅读详情


// ConverterWindow.xaml
 <Window x:Class="Xaml2XPS.ConverterWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Grid>
        <Button Height="23" HorizontalAlignment="Right" Margin="0,9,12,0" Name="btnConvert" VerticalAlignment="Top" Width="75" Click="btnConvert_Click">ToXPS</Button>
    </Grid>
</Window>

// ConverterWindow.xaml.cs
using System;
using System.Collections.Generic;
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.Shapes;
using System.IO;
using System.Windows.Markup;
using System.Windows.Xps.Packaging;
using System.Windows.Xps.Serialization;

namespace Xaml2XPS
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class ConverterWindow : Window
    {
        FileStream srcXamlStream = new FileStream(@"E:/WPF_Books/Chapter 10/Xaml2XPS/Files/CommonLogo.xaml", FileMode.Open);
        string destXpsFile = @"E:/WPF_Books/Chapter 10/Xaml2XPS/Files/Demo.Xps";

        public ConverterWindow()
        {
            InitializeComponent();        
        }

        private void btnConvert_Click(object sender, RoutedEventArgs e)
        {
            ParserContext context = new ParserContext();
            context.BaseUri = new Uri(Directory.GetCurrentDirectory() + "//");
            XamlStreamToXps(srcXamlStream, context, destXpsFile);
        }

        public void XamlStreamToXps(Stream srcXamlStream, ParserContext context, string destXpsFile)
        {
            XpsDocument document = null;
            try
            {
                if (System.IO.File.Exists(destXpsFile)) System.IO.File.Delete(destXpsFile);

                document = new XpsDocument(destXpsFile, FileAccess.Write);
                XpsPackagingPolicy packagePolicy = new XpsPackagingPolicy(document);
                XpsSerializationManager serializationMgr =
                    new XpsSerializationManager(packagePolicy, false);

                object parsedDocObject = (null == context) ?
                    XamlReader.Load(srcXamlStream) :
                    XamlReader.Load(srcXamlStream, context);

                serializationMgr.SaveAsXaml(parsedDocObject);
               

                MessageBox.Show("OK");
            }
            catch (Exception ex)
            {
                string exString = ex.Message;
                MessageBox.Show(exString);
            }
            finally
            { 
                if(document != null)   document.Close();
                if (srcXamlStream != null) srcXamlStream.Close();
            }
        }  
    }
}


来源(http://blog.csdn.net/johnsuna/article/details/2255417



从UE4到Unity:双叶高光技术在角色皮肤渲染中的移植全流程 本文详细解析了将UE4中的双叶高光技术移植到Unity引擎的全流程。该技术通过模拟皮肤油脂层和真皮层的不同反射特性,能显著提升角色皮肤渲染的真实感。文章从核心原理、贴图资产处理、Shader代码重构到参数调校,提供了完整的跨引擎移植实战指南,帮助开发者实现高质量的皮肤质感还原。 阅读详情

相关推荐

高效XPS转图片工具实战指南

虽然当前版本未开放完整插件系统,但可通过配置文件注入预处理脚本。例如,在转换前自动执行水印叠加:[CDATA[]]>未来可通过集成IronPython或JavaScript引擎(如Jint)实现真正的脚本宿主环境,允许用户编写:此类机制将极大增强工具的灵活性,适用于合同批处理、报表自动化等场景。

weixin_34618526的博客 1038

WPF通过XpsDocumentViewer打印Xaml页面 多页打印

经过:开始试过FlowDocument的方式通过xpsdocumentviewer来预览,但是流文档的方式数据绑定是硬伤;试过通过对窗口活用户控件截图然后插入word文件在进行打印,但是截图的质量达不到要求;最后摸索除了以下(多页打印)这种方式。 1、单个页面打印 var window = new MyWindow(); PrintDialog printDialog = n...

刺眼的博客 308

XPS阅读器官方工具XPS_Viewer完整安装包

XPS(XML Paper Specification)是微软推出的一种基于XML的固定布局文档格式,旨在提供与PDF功能类似的跨平台一致性展示能力。其核心特性在于采用Open Packaging Conventions(OPC)标准,将文档内容打包为ZIP容器,内部包含XAML描述的页面结构、字体、图像及数字签名等资源,确保视觉呈现精确还原。由于所有元素均封装于标准化部件中,XPS支持高保真打印、安全签名与加密,并天然适配Windows原生打印路径。

weixin_32445049的博客 488

WPF打印Xaml页面 多页打印 XpsDocumentViewer

WPF打印Window或者UserControl 多页

刺眼的博客 2108

wpf 大控件 打印 将控件转成 xps格式 并分页打印

//PayRollPrintList:要打印的 list 可换成自己要打印的类型 private List<PayRoll> _PayRollPrintList = new List<PayRoll>(); public List<PayRoll> PayRollPrintList { get...

weixin_30482383的博客 512

xps文件服务器端,XPS文档读取查看器

使用Microsoft Word,可以把文档另存为PDF或XPS文件。XPS是XML纸张规范(XML Paper Specification),是WPF的一个子集。Windows包含一个XPS读取器。因为XPS以ZIP文件格式打包,所以很容易把扩展名为xps文件重命名zip,打开该归档文件,来分析XPS文档XPS文件需要在zip文档中有XML纸张规范定义的特定结构。这个结构基于OPC,Word文...

weixin_42565652的博客 648

xps数据怎么导出为txt_WFP: 读取XPS文件或将word、txt文件转化为XPS文件

读取XPS格式文件或将doc,txt文件转化为XPS文件,效果图如下:1.XAML页面代码:xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="WordReader" Height="500" Wid...

weixin_33978578的博客 946

Convert XAML Flow Document to XPS with Style (multiple page, page size, header, margin)

http://blogs.msdn.com/b/fyuan/archive/2007/03/10/convert-xaml-flow-document-to-xps-with-style-multiple-page-page-size-header-margin.aspx

kissjob的专栏 1493

html5查看xps文件,c# – 在文档查看器中显示XPS文档

我正在使用文档查看器和XPS atm,因为我之前没有尝试过.所以我有一段简单的代码加载XPS文档并在文档查看器中显示它,但是文档没有出现.文档查看器加载并在调试模式下快速一步,告诉我信息在那里,它只是不会显示.dvDoc = new DocumentViewer();string fileName = null;string appPath = System.IO.Path.GetDirector...

weixin_39738380的博客 570

Convert XAML Flow Document to XPS with Style (multiple page, page size, header,

The original post is available here:    Convert XAML Flow Document to XPS with Style (multiple page, page size, header, margin)         XPS is a fixed document format in which pages are pre-for...

iteye_13882的博客 361

python处理xps文件_WFP: 读取XPS文件或将word、txt文件转化为XPS文件

读取XPS格式文件或将doc,txt文件转化为XPS文件,效果图如下:1.XAML页面代码:xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="WordReader" Height="500" Wid...

weixin_31865445的博客 1006

从DWG到XAML (II) - DWFx格式解析及其和XPS的关系

导读 第一篇: 从DWG到 XAML (I) - 浅谈DWG历史,现状及方向 第三篇: 从DWG到XAML (III) – .NET中的 XPS Packaging类库及一个DWFx Packaging类库的实现 (源码) 上一篇文章简单介绍了DWG格式的历史, 现状, 以及互操作的选择. 那么, AutoDesk宣称AutoCAD与XPS文件格式兼容, 究竟意味着什么呢? ...

weixin_30699443的博客 696

surfer15.zip

surfer15汉化,教程https://zwhclub.blog.csdn.net/article/details/148514305?spm=1001.2014.3001.5502

上一篇: 将普通文字转成路径(Path)的方法 (WPF,Silverlight,SVG)
下一篇: MVC中防止CSRF攻击
fer_ba
博客等级 码龄19年 21粉丝 59原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值