我应该如何在asp.net mvc 3中将数据导出到office文档和pdf

发布于 2024-12-10 00:06:07 字数 691 浏览 0 评论 0原文

我正在寻找解决这个问题的最佳方法以及我们最好的顺序。

我们有一个应用程序,用户可以在其中输入某些个人详细信息, 之后,他们可以下载个人数据的 Word 文档 (.docx) 或获取 pdf (.pdf)。

我们已经做的一切都是分开的: 使用 *.docx 模板,我们填充参数化字段,然后将其作为 docx 保存给用户

,并使用名为 BioPdf我们可以将渲染的word文档转换为

我们希望避免在服务器上安装office(或任何其他办公工具)的pdf, 因此当前的库需要删除,我们知道 iTextSharp 作为一个库创建 pdf,但这意味着每次模板更改时,我们都需要更新 word 文件的 *.docx 模板,同时更新呈现 pdf 的 iTextSharp 代码。

我们看待这个问题的方式是错误的吗? 我们应该以什么顺序生成这些文件,以便 - 最大限度地减少模板更改时的工作 - 服务器上没有安装任何办公程序

致以诚挚的问候 桑德·霍特基尔

i'm looking for the best way to tackle this issue and in what order we do it best.

we have an application where users can enter certain personal details,
afterwards they can download the word document (.docx) or get a pdf (.pdf) of their personal data.

what we already did is everything separate:
with a *.docx template, we fill the parameterized fields and then save it as docx to the user

and with a certain library called BioPdf we can convert the rendered word document into a pdf

we are looking to avoid having office installed (or any other office tool) on the server,
so the current library needs to go, we know of iTextSharp as a library to create pdfs, but that would mean that every time the template changes, we need to update our *.docx template for the word files, and at the same time update the iTextSharp code that renders our pdf.

are we looking at this the wrong way?
in what order should we generate these files, in order to
- minimize the work when a template gets changed
- have no office programs installed on the server

best regards
Sander Houttekier

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

英雄似剑 2024-12-17 00:06:07

由于我们仍然没有找到一个完全满足我们需要的免费库,因此我们正在认真考虑在 Aspose.Words 可以轻松满足我们的需要。

至少这是评估向我们展示的...

许多建议的库在某种程度上可以使用我们需要的数据生成 pdf,但不是我们想要的样式,我们需要一个具有模板 pdf 文件的系统,以填充一些参数,其中 1 个参数是产品列表,每个产品都在自己的表中,其中包含产品的几行数据,并且上述库都没有对此提供足够的支持,或者每个表都在自己的页面上,或者需要通过源代码创建的表格样式生成 pdf 时,虽然我们有不同的模板,但为每个模板的每种不同样式创建代码实在是太麻烦了。

因此,对 aspose 的免费替代品的追求仍在继续,但现在我将关闭这个替代品,因为我们找到了一个可以实现我们想要的功能的库。 (如果我查看 aspose.words 的价格,我只能假设他们知道他们是唯一提供这些功能的公司:P)

as we still have not found a free library that does exactly what we need, we are seriously thinking of buying a license on Aspose.Words which does what we need with ease.

at least that is what the evaluation shows us ...

many of the suggested libraries can to some point generate the pdf with the data we need, but not in the style we want, we needed a system where we have template pdf files, to be filled some parameters, 1 of those parameters beeing a list of products each in its own table with a few rows of data on the product, and none of the above libraries gave sufficient support for that, either every table was on its own page, or the style of the tables needed to be created via the source code generating the pdf, while we had different templates this would have been hell to create code for each different style of each template.

so the quest for a free alternative of aspose continues, but for now i will close this one as we found a library that does what we want. (and if i look at the prices of aspose.words, i can only assume they know they are about the only providing these features :P)

浅黛梨妆こ 2024-12-17 00:06:07

我首先使用 OpenXml SDK,它允许您以编程方式创建和操作 Office 文档。

它不需要您在服务器上安装 Microsoft Office 或获得许可,只需一个 DLL,如果需要,可以将其与应用程序的其余部分一起进行 bin 部署。

我还没有尝试过动态 PDF 生成(除了旧的 GhostScript),所以我无法提供任何建议。

I would start by using the OpenXml SDK, which will allow you to create and manipulate office documents programatically.

It does not require you to have Microsoft Office installed or licensed on your server, just a single DLL that can be bin-deployed along with the rest of your application if you want.

I haven't played around with dynamic PDF generation (apart from good old GhostScript), so I can't offer any advice there.

刘备忘录 2024-12-17 00:06:07

您可以尝试使用 PDFSharp 和 MigraDoc

似乎相同的代码可以在 PDF、打印机或屏幕中绘制。并且 MigraDoc 可以渲染为 RTF。

我计划将此与我的项目集成,但自己没有尝试,也许它适合您的项目。

You could have a try with PDFSharp y MigraDoc

It seems as the very same code can draw in a PDF, Printer or Screen.. and MigraDoc can render to RTF.

I had this scheduled to integrate with my projects but didn't try it myself, perhaps it fits your project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文