使用XML,XSLT和C#创建RTF或PDF [英] Using XML, XSLT and c# to create an RTF or PDF

查看:147
本文介绍了使用XML,XSLT和C#创建RTF或PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:
的用户已通知我,他将接受PDF格式还

我要创建一个简单的RTF或在服务器端代码的PDF文件,并​​就今后的下载网络驱动程序保存。

I have to create a simple RTF or PDF document in server side code and save on a network driver for future downloading.

这封信会从我已经存储在SQL Server(2005)信息填充。我访问使用LINQ到SQL模型的DATABSE。该文件将由一个ASP.Net MVC 1.0前端进行下载。

The letter will be populated from info that I have stored in a SQL Server (2005). I access the databse using a Linq-to-Sql model. The document will be downloaded by a ASP.Net MVC 1.0 front end.

该文件的结构将是非常基本的。它与它的一些基本信息的信。

The structure of the file will be pretty basic. Its a letter with some basic info on it.

我已经做了一些冲浪和见过几个职位,建议我使用XSLT来生成RTF文档。

I have done some surfing and seen a few post recommending that I use XSLT to generate the RTf document.

谁能推荐这个一个很好的教程?我以前从未使用XSLT,所以一个傻瓜教程将是伟大的!

Can anyone recommend a good tutorial on this? I've never used XSLT before, so a "For Dummies" tutorial would be great!

其他技术建议,将不胜感激。寻找一个快速的胜利,并不需要是完美的解决方案。

Any other technology suggestions would be appreciated. Looking for a quick win, doesn't need to be the perfect solution.

感谢

C

推荐答案

如果你采用这种方式,那么你会运行工作流将沿着线的东西:

If you adopt this approach then the workflow you'll run will be something along the lines of:


  1. SQL服务器 - >内部表示

  2. 内部表示 - > XML表示(可能使用LINQ to XML)

  3. XML + XSLT - >输出表示

基本上,XSLT所做的是让你把XML,并根据一组规则是不是程序更多的功能从它生成的文本及其不同的的。已经登上了学习曲线,我已经有很多使用XSLT(主要是生产HTML文档)的成功。我上了很多倚书上手是第一版:XSLT:掌握XML转换。对于由道格·蒂德韦尔(其中,与长标题,现在是第二版)初学者和高级用户。

Basically what XSLT does is allow you to take XML and generate text from it according to a set of rules that are more functional than procedural its different. Having ascended the learning curve I've had a lot of success with XSLT (mostly producing HTML documents). The book that I leant on a lot to get started was the first edition of: XSLT: Mastering XML Transformations. For Beginners and Advanced Users by Doug Tidwell (which, with that long title, is now a second edition).

的实际问题是你要生产从文档一个模板 - 即您将有一组数据将您能够通过数据机械倾倒入一个框架来创建需要的文件?在这方面的好消息是,你可以做一个的很多的使用XSLT。更好的消息是,你可以从应用程序单独存储XLST,这使得它更容易调整的事情,还为您提供具有可根据需要采用多个模板的选项。

The practical question is do you want to produce a document from a template - that is you'll have a set of data will you be able to create the required document by mechanically dumping the data into a framework? The good news in this respect is that you can do a lot with XSLT. The better news is that you can store the XLST separately from the application, this makes it easier to tweak things and also gives you the option of having multiple templates that can be applied as required.

由于RTF是一个文本文档格式,你应该能够生产从XLST需要什么

Since RTF is a text document format (?) you should be able to produce what you need from XLST.

与PDF的问题 - 如果下去了XSLT的路线是,你需要的东西,XSL-FO转换成PDF文档,不仅会推出更多的复杂性和 - 中速赢的方面 - 相当多的学习

The problem with PDF - if going down the XSLT route is that you need something to convert XSL-FO into a PDF document, not only that it will introduce more complexity and - in terms of a quick win - quite a bit more to learn.

您的选择是从内部模型直产生RTF或PDF。你失去了模板的能力,但把自己更接近你的基本舒适(代码) - 在这方面isharptext已经有好东西说,大约是溜

Your alternative is to generate RTF or PDF straight from your internal model. You lose the templating capability but bring yourself closer to your basic comfort (code) - in this respect isharptext has had nice things said about it hereabouts.

我同意W3Schools的的东西。

I agree about the w3schools stuff.

我已经上了一点,但问题是,是的,它应该让你想你需要,将是一个积极的,灵活的除了你工具包,但你可以沿途遭受一些痛苦(XSLT是不是程序代码,如果你试图把这种方式,你就很难)。

I've gone on a bit, but the point is that yes, it should let you do want you need and will be a positive and flexible addition to your toolkit but you may suffer some pain along the way (XSLT is not procedural code, if you try and treat it that way you'll struggle).

这篇关于使用XML,XSLT和C#创建RTF或PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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