diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-01-17 15:19:17 +0000 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-01-17 15:19:17 +0000 |
commit | 3bb07659f8185cf8ba58c5d4766321f23ce3a9f1 (patch) | |
tree | c39eda7fbb812bf5baf1433d1fae8d484544b9c1 | |
parent | 604ec14bc34d4c7b64b7ca36d9fcda03e51daea6 (diff) |
Use AlaveteliExternalCommand for pdf recompression
-rw-r--r-- | app/models/incoming_message.rb | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 0b4ce7b27..07736c902 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -277,15 +277,11 @@ class IncomingMessage < ActiveRecord::Base # then use the altered file (recompressed) recompressed_text = nil if MySociety::Config.get('USE_GHOSTSCRIPT_COMPRESSION') == true - command = "gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=- -" + command = ["gs", "-sDEVICE=pdfwrite", "-dCompatibilityLevel=1.4", "-dPDFSETTINGS=/screen", "-dNOPAUSE", "-dQUIET", "-dBATCH", "-sOutputFile=-", "-"] else - command = "#{"pdftk"} - output - compress" - end - IO.popen(command, "r+") do |child| - child.write(censored_uncompressed_text) - child.close_write() - recompressed_text = child.read() + command = ["pdftk", "-", "output", "-", "compress"] end + recompressed_text = AlaveteliExternalCommand.run(*(command + [{:stdin_string=>censored_uncompressed_text}])) if recompressed_text.nil? || recompressed_text.empty? # buggy versions of pdftk sometimes fail on # compression, I don't see it's a disaster in |