Skip to content

Instantly share code, notes, and snippets.

@som-poddar
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save som-poddar/8137c986b37e036444bc to your computer and use it in GitHub Desktop.
Save som-poddar/8137c986b37e036444bc to your computer and use it in GitHub Desktop.
pdf-reader
require 'pdf/reader'
raw_string = ''
#INSTRUCTION: save it locally http://www.energy.umich.edu/sites/default/files/pdf-sample.pdf
filename = File.expand_path(File.dirname(__FILE__)) + '/pdf-sample.pdf'
PDF::Reader.open(filename) do |reader|
reader.pages.each do |page|
raw_string = page.raw_content
puts page.raw_content
end
end
#check if 'raw_string' is Malformed PDF or not
PDF::Reader.new(StringIO.new(raw_string))
puts 'done'
@som-poddar
Copy link
Author

trying to find out why I keep getting ``find_first_xref_offset': PDF does not contain EOF marker (PDF::Reader::MalformedPDFError)` error.

note: this gist requires pdf-reader gem (https://github.com/yob/pdf-reader)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment