我需要为当前托管在 Appharbor 上的一个 .Net Web 应用程序生成 PDF。
传统上,我只是在机器上安装 Latex,然后使用 pdflatex 即时创建 PDF。此要求是向最终用户显示 HTML 中的部分,但也有可下载的 PDF - 因此略有不同。
我发现了几个(免费的)外部 HTML 到 PDF 转换器,它们可能适用于这种情况。但是,我还没有找到任何库允许我纯粹以编程方式执行此操作。
如果我打算继续使用 Appharbor,您会给我什么建议?
我是否应该设置一个单独的 EC2(或类似)实例来运行此类应用程序?或者有更好的选择吗?
I have a requirement to produce PDF's for one my .Net web applications currently hosted on Appharbor.
Traditionally, I would simply install latex on the machine, and create PDF's on the fly with pdflatex. This requirement is to display sections in HTML to end users, but also have a downloadable PDF - so it's slightly different.
I have found several (free) external HTML to PDF converters which may be applicable in this instance. However, I haven't found any libraries allowing me to do this purely programatically.
What advice would you give if I plan to continue using Appharbor?
Should I set up a seperate EC2 (or similar) instance to run such an application from? Or is there a better alternative?
发布评论
评论(2)
我建议使用类似 DocRaptor 的东西。请注意,如果您将相关的 pdflatex 可执行文件(并且不需要整个 Latex 运行时)与推送到 AppHarbor 的代码一起放置,您可能可以继续当前的方案。 AppHarbor 还将引入后台工作人员,这可能是非常适合此类工作。
I'd recommend using something like DocRaptor. Note that you can probably continue with your current scheme if you place the relevant pdflatex executable (and it doesn't require the entire Latex runtime) alongside the code you push to AppHarbor. AppHarbor will also be introducing background workers, which might be a good fit for this sort of work.
请注意,如果您尝试使用 Rotativa 或使用 wkhtmltopdf 以及从 HttpContext 获取的路由,则需要使用此解决方法:
http://support.appharbor.com/kb/getting-started/workaround-for-generate-absolute-urls-without-port-number
或从 Nuget 安装 premotion 修复程序:
< a href="https://github.com/trilobyte/Premotion-AspNet-AppHarbor-Integration" rel="nofollow">https://github.com/trilobyte/Premotion-AspNet-AppHarbor-Integration
Note that if you're trying to use Rotativa or using wkhtmltopdf with routes obtained from HttpContext you'll need to use this workaround:
http://support.appharbor.com/kb/getting-started/workaround-for-generating-absolute-urls-without-port-number
or install the premotion fix from Nuget:
https://github.com/trilobyte/Premotion-AspNet-AppHarbor-Integration