Skip to content

Instantly share code, notes, and snippets.

@harikrishnan83
Last active August 29, 2015 14:02
Show Gist options
  • Save harikrishnan83/c9c94cd9b67842516af8 to your computer and use it in GitHub Desktop.
Save harikrishnan83/c9c94cd9b67842516af8 to your computer and use it in GitHub Desktop.
Convert all pages with Carrierwave::MiniMagick
# MiniMagick::Image.format method by default converts only the first page.
# Carrierwave::MiniMagick.convert(:pdf) does not allow us to pass a second parameter page = nil.
# We need to paste in below code in the carrierwave initializer (or you may choose to extract it to lib folder)
# and use convert_all_pages_to_pdf in you uploader.
module CarrierWave
module MiniMagick
def convert_all_pages_to_pdf
manipulate! do |img|
img.format('pdf', nil)
img = yield(img) if block_given?
img
end
end
end
end
@harikrishnan83
Copy link
Author

Latest versions of CarrierWave should not have this issue.
carrierwaveuploader/carrierwave#1408

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment