如何设置 pdftk 或 iText 以便与 Heroku 上的 Rails 3 一起使用?

发布于 2024-10-14 06:04:20 字数 233 浏览 8 评论 0原文

我正在尝试找到一种方法将 FDF 文件内容注入可填充的 PDF 文件(由客户提供,不应该使用 Prawn 或 PDFKit 进行“重新绘制”),并且我认为我必须使用 iText(与 JRuby) ) 或 pdftk.

这两个库在我的 Ubuntu 本地计算机上都没有问题,但我想知道如何让它们在 Heroku 上工作。有没有人尝试过让 iText(JRuby) 或 PDFTK 在 Heroku 上工作?

感谢您的帮助!

I'm trying to find a way to inject FDF file content into a fillable PDF file (provided by customer and not supposed to be 're-drawn' using Prawn or PDFKit), and I think I have to use either iText(with JRuby) or pdftk.

Both of these libs work with no problem on my Ubuntu local machine, but I am wondering how I would get either them to work on Heroku. Has anyone tried to get iText(JRuby) or PDFTK to work on Heroku ?

Thanks for your help!

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

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

发布评论

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

评论(1

梦过后 2024-10-21 06:04:20

您可以在 Heroku 上使用 pdftk – 它是预安装的。您可以通过从 Ruby 应用程序中将其作为命令行程序来使用它。

对于大多数 pdftk 命令,您将使用 Tempfile。将参数中的 Tempfile#path 插入到 pdftk 中。

`pdftk #{subcommand}`
raise Exception unless $?.success?

在某些情况下,您将能够使用 stdinstdout 而不是 Tempfile 通过管道传入和传出数据。

input = ...
output = IO.popen "pdftk #{subcommand}", 'w+b' do |io|
  io.write input
  io.flush
  io.close_write
  io.read
end

You can use pdftk on Heroku – it's pre-installed. You use it by shelling out to it as a command-line program from within your Ruby app.

For most pdftk commands, you will use Tempfiles. Interpolate the Tempfile#paths in the arguments to pdftk.

`pdftk #{subcommand}`
raise Exception unless $?.success?

In some cases, you will be able to pipe data in and out using stdin and stdout rather than Tempfiles.

input = ...
output = IO.popen "pdftk #{subcommand}", 'w+b' do |io|
  io.write input
  io.flush
  io.close_write
  io.read
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文