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!
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 Tempfile
s. Interpolate the Tempfile#path
s 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 Tempfile
s.
input = ...
output = IO.popen "pdftk #{subcommand}", 'w+b' do |io|
io.write input
io.flush
io.close_write
io.read
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With