Last active
August 29, 2015 14:11
-
-
Save som-poddar/8137c986b37e036444bc to your computer and use it in GitHub Desktop.
pdf-reader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)