C# LaTeX 用于生产中的 PDF 生成
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1210334/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
LaTeX for PDF generation in production
提问by codelove
I used LaTeX for writing couple of white papers while I was in grad school. From that I have a really good impression about it in terms of what LaTeX allows user to do, especially the fine control it provides over formatting, etc.
我在读研究生时使用 LaTeX 写了几篇白皮书。从那以后,我对 LaTeX 允许用户执行的操作有很好的印象,尤其是它对格式提供的精细控制等。
Now I am debating whether I should actually use LaTeX for our production apps to generate PDFs. I have tried several commercial and free PDF libraries (PDFSharp/MigraDoc, iTextSharp, Expert PDF, etc) and none of them provide the amount of fine control I need without making the code base extremely difficult to maintain in long run.
现在我在争论是否应该在我们的生产应用程序中使用 LaTeX 来生成 PDF。我已经尝试了几个商业和免费的 PDF 库(PDFSharp/MigraDoc、iTextSharp、Expert PDF 等),但它们都没有提供我需要的精细控制量,而不会使代码库长期难以维护。
If I do decide to go this route it will be done from C#. Since LaTeX already has command line interface, I should be able to do that pretty easily from C# as an external process forked from my program.
如果我决定走这条路线,它将从 C# 完成。由于 LaTeX 已经有命令行界面,我应该能够很容易地从 C# 中做到这一点,因为它是从我的程序派生出来的外部进程。
But I was looking for some comments from the community.
但我正在寻找来自社区的一些评论。
- Has anyone tried it? If so, what were some gotchas?
- What do you think about the idea -- pros and cons (I am more interested in gotachas)?
- 有没有人试过?如果是这样,有什么问题?
- 您如何看待这个想法 - 利弊(我对gotachas更感兴趣)?
All feedback is welcome.
欢迎所有反馈。
采纳答案by jason
I have previously built a platform for report generation that uses plain TeX (specifically the MiKTeX implementation) to generate reports in PDF format. The platform is used to generate approximately fifty reports per month of varying nature (containing mostly dynamically generated tables and charts). The system is quite flexible. Reports are defined via XML (on an internally-defined report description schema). The platform allows the user to specify a source database table, which fields to extract, the formatting of the fields, a mini query language to filter the appropriate data as well as various formatting elements (page orientation, size, titles, and classifications ("Public", "Internal", "Confidential", etc.).
我之前构建了一个报告生成平台,该平台使用普通 TeX(特别是MiKTeX 实现)生成 PDF 格式的报告。该平台用于每月生成大约 50 份不同性质的报告(主要包含动态生成的表格和图表)。该系统非常灵活。报告是通过 XML 定义的(在内部定义的报告描述架构上)。该平台允许用户指定源数据库表、要提取的字段、字段的格式、用于过滤适当数据的迷你查询语言以及各种格式元素(页面方向、大小、标题和分类(“公开”、“内部”、“机密”等)。
The main "gotcha" is that it takes a ton of work to end up with a code base that is flexible to change and not a total pain to maintain. A second "gotcha" is that knowledge of TeX (outside of academics) is rare so you could end up becoming the de facto maintainer even if that is not part of your usual role.
主要的“问题”是需要大量的工作才能最终得到一个可以灵活更改的代码库,而不是维护起来很痛苦。第二个“陷阱”是 TeX 的知识(学术之外)很少见,因此即使这不是您通常角色的一部分,您最终也可能成为事实上的维护者。
Pros:
优点:
- Beautifully formatted reports.
- Complete control over layout and look.
- Free.
- 格式精美的报告。
- 完全控制布局和外观。
- 自由。
Cons:
缺点:
- Difficult to implement properly.
- Difficult to maintain.
- Knowledge transition could be burdensome.
- Support is effectively non-existant.
- 难以正确实施。
- 难以维护。
- 知识转移可能是繁重的。
- 支持实际上是不存在的。
回答by Mark Rushakoff
I've done a few in-house "production level" documents in LaTeX.
我已经在 LaTeX 中完成了一些内部“生产级”文档。
Generating LaTeX documents in Windows is an overall horrible experience, to be honest. I was never able to find any solution besides Cygwin. Once you've got the Cygwin environment up and running, it was as simple as picking out the LaTeX and related libraries from Cygwin's setup.exe
.
老实说,在 Windows 中生成 LaTeX 文档总体上是一种可怕的体验。除了 Cygwin,我一直找不到任何解决方案。一旦您启动并运行了 Cygwin 环境,就像从 Cygwin 的setup.exe
.
I haven't tried running LaTeX from a non-Cygwin environment, but in theory you should be able to just run C:\Cygwin\usr\bin\latex.exe
-- then there's a chance it will be missing paths since you're not in Bash, in which case you might need to just pass the include directories to subsequent programs.
我没有尝试在非 Cygwin 环境中运行 LaTeX,但理论上你应该能够运行C:\Cygwin\usr\bin\latex.exe
——然后有可能因为你不在 Bash 中而丢失路径,在这种情况下你可能需要只需将包含目录传递给后续程序。
If you decide to use Docbook instead of LaTeX for your documentation (and I would recommend at least giving it a look, it's muchmore structured for software-related technical documentaion), I had good experience running dblatexunder Cygwin. It's not in the Cygwin repositories, but it's a piece of cake to install from source.
如果您决定在文档中使用 Docbook 而不是 LaTeX(我建议至少看看它,它对于与软件相关的技术文档来说更加结构化),我在 Cygwin 下运行dblatex有很好的经验。它不在 Cygwin 存储库中,但从源代码安装它是小菜一碟。
回答by janm
I have done various production PDF implementations using TeX. I ended up abandoning LaTeX, and went with ConTeXt(see also Context Garden).
我已经使用 TeX 完成了各种生产 PDF 实现。我最终放弃了 LaTeX,转而使用ConTeXt(另见Context Garden)。
There is a very active mailing list, it is used extensively for document production, and there is a nice minimal distribution for various Unixes, Windows and Mac OS X. There is no need for Cygwin on Windows (although you do need Ruby).
有一个非常活跃的邮件列表,它广泛用于文档制作,并且有一个适用于各种 Unix、Windows 和 Mac OS X 的不错的最小发行版。Windows 上不需要 Cygwin(尽管您确实需要 Ruby)。
I find ConTeXt approach to TeX cleaner than LaTeX, but that might just be me.
我发现 ConTeXt 的 TeX 方法比 LaTeX 更干净,但这可能只是我。
回答by Thierry
If you need to publish data summaries and graph, then you can have a look at Sweave. Sweave allows to mix all the functionality of Rwith TeX. The source code of a report consist of a plain TeX file with some R-code chunk were you need to read, manipulate, tabulate or plot data. Then you 'compile' the Sweave file (from the commandline) which returns a plain TeX file.
如果你需要发布数据摘要和图表,那么你可以看看Sweave。Sweave 允许将R 的所有功能与 TeX 混合。报告的源代码由一个普通的 TeX 文件和一些 R 代码块组成,您需要读取、操作、制表或绘制数据。然后你'编译' Sweave 文件(从命令行),它返回一个普通的 TeX 文件。