Reading Metadata

20 views
Skip to first unread message

Bala Paranj

unread,
Sep 11, 2014, 2:25:14 PM9/11/14
to origa...@googlegroups.com
Is it possible to read the meta-data of the PDF such as the author name using this gem? TIA.

Bala Paranj

unread,
Sep 11, 2014, 5:04:45 PM9/11/14
to origa...@googlegroups.com
I am able to read the meta-data. However I am getting an error when modifying the meta-data as follows:

require 'origami'

include Origami

pdf = PDF.read('test.pdf')
meta_data = pdf.get_metadata

puts meta_data.class
puts meta_data

puts "Title : #{meta_data['title']}"
puts "Creator : #{meta_data['creator']}"

puts "Author string encoding is : #{meta_data['creator'].encoding}"

puts "Title has ascii only : #{pdf.title.ascii_only?}"
puts "Author has ascii only : #{pdf.author.ascii_only?}"
pdf.create_metadata({:author => 'Bugs Bunny'})
pdf.save('./test2.pdf')
# save fails : incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)

Any pointers on how to fix this error?
Reply all
Reply to author
Forward
0 new messages