“乳胶导轨” gem 不生成输出
我对“乳胶导轨”宝石有疑问。我正在尝试创建一个可以生成 pdf 的函数。这是我的代码:
code = "\\documentclass[12pt]{article}
\\begin{document}
Don't forget to include examples of topicalization.
\\end{document}"
@latex_config={:command => 'xelatex',:parse_twice => true}
LatexToPdf.generate_pdf(code, @latex_config, parse_twice = true)
在日志文件中,我可以看到“输出写入 input.pdf(1 页)”,但没有 input.pdf,我不知道出了什么问题。
I have a problem with "latex-rails" gem. I`m trying to make function which will generate a pdf. This is my code:
code = "\\documentclass[12pt]{article}
\\begin{document}
Don't forget to include examples of topicalization.
\\end{document}"
@latex_config={:command => 'xelatex',:parse_twice => true}
LatexToPdf.generate_pdf(code, @latex_config, parse_twice = true)
In a log file I can see that "Output written on input.pdf (1 page).", but there is no input.pdf and I have no clue what is wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了在这里发布答案而不是在评论中...
LatexToPdf.generate_pdf 方法返回 pdf 二进制文件本身,您需要将其写入文件。这是实现此目的的一种方法:
正如您所指出的,日志文件表明输出已写入文件;然而,rails-latex 将此文件写入临时目录,并在方法结束时销毁该目录(因此需要自己将返回的二进制内容写入文件)。
For the sake of having an answer posted here instead of in the comments...
The LatexToPdf.generate_pdf method returns the pdf binary itself, which you'll need to write to a file. Here's one way to accomplish this:
As you noted, the log file states that the output was written to a file; however, rails-latex writes this file to a temporary directory and destroys the directory at the end of the method (hence the need to write the returned binary content to a file yourself).