WPF为XPS为PDF [英] WPF to XPS to PDF
问题描述
我已经实现了在标准WPF控件的报告,还实施了一个 DocumentPaginator
来采取这些控件并将它们转换成打印文档。
I have implemented a report in standard WPF controls and have also implemented a DocumentPaginator
to take these controls and convert them into a document for printing.
我也实现了一些code,它使用文档分页程序来渲染页面的图像和使用的 PDFSharp 的,然而,这不允许复制和粘贴,也图像质量是有问题的。
I have also implemented some code which uses the document paginator to render the pages to images and write them out to a PDF using PDFSharp, however this does not allow for copying and pasting, also the image quality is questionable.
我已经尝试与 GhostXPS 实用工具,并考虑使用它通过节省出XPS文档和然后使用 GhostXPS ,以将其转换为PDF格式,这是有希望的,但目前的版本包含呈现数据中的错误从生成的PDF复制没用...
I have experimented with the GhostXPS utility and was thinking of using it by saving out to an XPS document and then using GhostXPS to convert it to a PDF, this was promising, however the current version contains a bug that renders data copied from the generated PDF useless...
所以,我想我会问这里,试图找到一种有效的方法,这样做,是否有人可以提出一个很好的方式,采取一个 DocumentPaginator
并直接保存出到PDF,具有复制/粘贴功能或将其转换的XPS文档为PDF使用这一功能?
So I thought I would ask here to try and find a efficient method for doing this, Can someone please suggest a good way to take a DocumentPaginator
and either save it directly out to a PDF, with copy/paste functionality or convert it from an XPS document to a PDF with this functionality?
谢谢, 亚历克斯。
编辑 - PDFSharp修复: 确定的要求这里是我做编译为PDFSharp 1.31 XPS转换器的修补程序:
EDIT - PDFSharp fix: Ok as requested here is what I did to compile the fix for the PDFSharp 1.31 XPS converter:
1)我下载的来源从这里开始:
1) I downloaded the source from here:
2)我跟着这个帖子的指令:
2) I followed the instruction in this post:
XpsParser.ImageBrush.cs (ln 22, added): brush.Opacity = 1;
PdfContentWriter.cs (ln 526, changed): if (opacity <= 1)
3)然后,只需编译源代码,先打开PdfSharp-WPF.csproj和构建,然后打开PdfSharp.Xps.csproj,并建立它为好,相应和库PdfSharp,WPF。 DLL'和'PdfSharp.Xps.dll
3) Then just compile the source, first open the 'PdfSharp-WPF.csproj' and build that, then open the 'PdfSharp.Xps.csproj' and build it as well, the relevent libraries are 'PdfSharp-WPF.dll' and 'PdfSharp.Xps.dll'
注在试图打造您可能会收到这取决于你的目标.NET版本,这些都是简单的修复,如果你只是读取错误消息的一些错误的根源。
Note upon trying to build the source you will likely receive a few errors depending on which version of .NET you are targeting, these are simple to fix if you just read the error messages.
编辑(2):NJones创建了一个博客帖子上的PdfSharp修补程序的详细信息:的输出为PDF在WPF
EDIT(2): NJones created a blog post with more details on the PdfSharp fix: Output to PDF in WPF
推荐答案
目前所包含的PDFsharp 1.31的XPS转换器。这是一个测试版,但AFAIK它支持几乎所有并可能对您的需求。
There is an XPS Converter that was included with PDFsharp 1.31. It's a beta version, but AFAIK it supports nearly everything and may work for your needs.
PDFsharp 1.31可以从SourceForge或codePLEX进行下载。
PDFsharp 1.31 can be downloaded from SourceForge or CodePlex.
这篇关于WPF为XPS为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!