Class: Paperclip::DocsplitPdf
Instance Attribute Summary
#attachment, #options, #src
Instance Method Summary
collapse
#initialize, #src_path
Instance Method Details
#make ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/processors/docsplit_pdf.rb', line 3
def make
begin
dst_dir = Dir.tmpdir
dst_path = File.join(dst_dir, "#{@basename}.pdf")
if pdf_format?
dst_path = File.join(dst_dir, "_#{@basename}.pdf")
FileUtils.copy_file(src_path, dst_path)
else
Docsplit.(src_path, :output => dst_dir)
end
rescue Exception => e
raise Paperclip::Error, "There was an error converting #{@basename} to pdf"
end
File.open(dst_path)
end
|
20
21
22
23
24
25
|
# File 'lib/processors/docsplit_pdf.rb', line 20
def pdf_format?
file_magic = FileMagic.new
type = file_magic.file(src_path)
file_magic.close
type =~ /pdf/i
end
|