Skip to content

Instantly share code, notes, and snippets.

@mic-kul
Created May 17, 2018 12:48
Show Gist options
  • Save mic-kul/12901c232a92b257ff4b4a56b262d363 to your computer and use it in GitHub Desktop.
Save mic-kul/12901c232a92b257ff4b4a56b262d363 to your computer and use it in GitHub Desktop.
PDF Textstream
def self.file_path_to_text(path)
# TODO: exception handling
pdfParser = PDFParser.new(RandomAccessFile.new(Java::JavaIo::File.new(path), "r"))
pdfParser.parse()
pdDocument = PDDocument.new(pdfParser.getDocument());
pdfTextStripper = PDFLayoutTextStripper.new
string = pdfTextStripper.getText(pdDocument);
return string
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment