[不是问题]从WPF窗口内容生成PDF [英] [Not a question] PDF Generation from WPF window content

查看:67
本文介绍了[不是问题]从WPF窗口内容生成PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在开发wpf应用程序....在我的应用程序中,我有计费部分......在生成帐单之后,我想将该帐单的总体视图放入pdf文件并下载给用户....请提供下载窗口内容为pdf文件的代码?

Hello,
I am working on wpf application.... In my application I have billing section ... After the bill generation I want to place that total view of the bill into a pdf file and download it for the User....Please provide the code for downloading the content of window into pdf file?


推荐答案

通常我们不回答GimmeCode非问题(这不是问题,因为任何人都可以......?不能算作问题),但在这种特殊情况下,纯粹的技术/科学答案是可能的:没有人可以通过一个原则理由给你这样的代码:没有明确的转换从一个到另一个,因为这两种对象有不同的概念不可能进行一对一的通信。 PDF文件类似于电子纸,所有数据都以固定的方式表示。相反,应用程序窗口是流动的,它根据屏幕和窗口大小以及应用程序的状态,输入的数据以及类似的东西而采用不同的形状。问题只是含糊不清。



这并不意味着代码执行此类操作以满足某些要求无法编写。根据你的问题,没有人可以把它给你。获得此类任务需要两个输入流:1)您的应用程序本身,就像在实现此类功能之前一样; 2)映射规则将描述应用程序的状态应如何映射到PDF输出。



为了创建PDF,您可以使用iText或其.NET端口,iTextSharp:

http://en.wikipedia.org/wiki/IText [ ^ ],

http://itextpdf.com/ [ ^ ],

http://sourceforge.net/projects/itextsharp/ [ ^ ]。



包括对Java iText网站的引用,因为大多数文档都在那里。如果您了解C#,那么理解基于Java的API文档并不困难。



-SA
Usually we don't answer "GimmeCode" non-questions (this is not a question, because "can anyone… ?" cannot be counted as a question), but in this particular case, a purely technical/"scientific" answer is possible: no one can give you such code by one principle reason: there is no unambiguous "conversion" from one to another, because the two kinds of object have different concept leaving no possibility for one-to-one correspondence. PDF file is something like an electronic paper, all data represented in a fixed way. An application window, in contrast, is fluid, it takes different shapes depending on screen and window size and the state of the application, entered data, and anything like that. The problem is just ambiguous.

It does not mean that the code doing something like this to meet certain requirements cannot be written. It's just that no one can give it to you based on your question. There are two flows of input needed to get to such a task: 1) your application itself, as it is before implementing such feature, 2) the mapping rules which would describe how the state of the application should be mapped on PDF output.

For creation of PDF, you can iText, or its .NET port, iTextSharp:
http://en.wikipedia.org/wiki/IText[^],
http://itextpdf.com/[^],
http://sourceforge.net/projects/itextsharp/[^].

In included the reference to Java iText site as well, because most documentation is there. If you understand C#, it would not be difficult to understand Java-bases API documentation.

—SA

这篇关于[不是问题]从WPF窗口内容生成PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆