PDF Previews with Rails 6 Active Storage

Posted on

You can use the .preview method on Active Storage objects (which contain a PDF or videos) to create image previews of the content within the file.

It’s really fun to use, plus it only requires a few lines of code to get setup. It does require installing Poppler (for PDF previews) and FFmpeg (for video previews) which I’ll covered in the video.


Sample Files: https://github.com/MikeRogers0-YouTube/ActiveStorage-Image-Resizing ActiveStorage::Preview Documentation: https://api.rubyonrails.org/v6.1.0/classes/ActiveStorage/Preview.html Poppler: https://en.wikipedia.org/wiki/Poppler_(software) FFmpeg: https://en.wikipedia.org/wiki/FFmpeg Heroku Active Storage Buildpack: https://github.com/heroku/heroku-buildpack-activestorage-preview