PDFlib Text Extraction Toolkit (TET) Manual
PDFlib Text Extraction Toolkit (TET) Manual
PDFlib Text Extraction Toolkit (TET) Manual
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
oot :to => "home#demo"<br />
> Edit app/controllers/home_controller.rb as follows and insert <strong>TET</strong> code for extracting<br />
PDF contents. As a starting point you can use the code in the extractor-rails.rb sample:<br />
class HomeController < ApplicationController<br />
def demo<br />
require "<strong>TET</strong>"<br />
begin<br />
p = <strong>TET</strong>.new<br />
doc = tet.open_document(infilename, docoptlist)<br />
...<strong>TET</strong> application code, see extractor-rails.rb...<br />
...<br />
# and finally show the retrieved text<br />
send_data text, :type => "text/plain", :disposition => "inline"<br />
rescue <strong>TET</strong>Exception => pe<br />
# error handling<br />
end<br />
end<br />
end<br />
> In order to test your installation start the WEBrick server with the command<br />
$ rails server<br />
and point your browser to http://0.0.0.0:3000. The text extracted from the PDF document<br />
will be displayed in the browser.<br />
Local <strong>TET</strong> installation. If you want to use <strong>TET</strong> only with Ruby on Rails, but cannot install<br />
it globally for general use with Ruby, you can install <strong>TET</strong> locally in the vendors directory<br />
within the Rails tree. This is particularly useful if you do not have permission to install<br />
Ruby extensions for general use, but want to work with <strong>TET</strong> in Rails nevertheless.<br />
40 Chapter 3: <strong>TET</strong> Library Language Bindings