blob: 31a2a8f1206a967ee5ea3ce8910b1c1c74f61a90 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# frozen_string_literal: true
module ActiveStorage
class Previewer::PDFPreviewer < Previewer
def self.accept?(blob)
blob.content_type == "application/pdf"
end
def preview
open do |input|
draw "mutool", "draw", "-F", "png", "-o", "-", input.path, "1" do |output|
yield io: output, filename: "#{blob.filename.base}.png", content_type: "image/png"
end
end
end
end
end
|