MikeRogers0/MikeRogersIO

View on GitHub
src/_videos/2021-01-11-pdf-previews-with-rails-6-active-storage.md

Summary

Maintainability
Test Coverage
---
layout: video
title: PDF Previews with Rails 6 Active Storage
youtube_id: W_A4wWW3uaU
published_at: '2021-01-11T17:04:34Z'
---
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.

# Sources

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

# Chapters

0:00 - What are we going to do?
0:18 - What happens if we upload a PDF?
1:03 - Which libraries do we need to install?
2:02 - Installing poppler-util & ffmpeg
3:03 - Uploading PDFs, videos & images
5:16 - The Heroku Buildpack
5:37 - Summary & Thank you

# Support Me

- https://twitter.com/mikerogers0
- https://mikerogers.io
- https://www.buymeacoffee.com/MikeRogers0

#ActiveStorage
#RubyOnRails
#PDFPreview