Sha256: f80400276f32a211d8ec45bfb45fd9b22e549f04965b9a6a0614c192dc276033

Contents?: true

Size: 1.73 KB

Versions: 3

Compression:

Stored size: 1.73 KB

Contents

#!/usr/bin/env ruby
#
#	Rpdf2txt -- PDF to Text Parser
#	Copyright (C) 2003 Andreas Schrafl, Hannes Wyss
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#	ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zürich, Switzerland
#	hwyss@ywesee.com,	aschrafl@ywesee.com
#
# TextParser -- Rpdf2txt -- 19.12.2002 -- hwyss@ywesee.com 

require 'rpdf2txt-rockit/rockit'

module Rpdf2txt
		TEXT_GRAMMAR = File.expand_path('data/pdftext.grammar', File.dirname(__FILE__))
		TEXT_PARSER = File.expand_path('data/pdftext.rb', File.dirname(__FILE__))
		def text_parser(grammar_path=TEXT_GRAMMAR, parser_path=TEXT_PARSER)
			oldpath = File.dirname(grammar_path) << "/_" << File.basename(grammar_path)
			src = File.read(grammar_path)
			unless(File.exists?(oldpath) && File.read(oldpath)==src)
				File.delete(oldpath) if File.exists?(oldpath)
				Parse.generate_parser_from_file_to_file(grammar_path, parser_path, '_text_parser', 'Rpdf2txt')
				File.open(oldpath, 'w') { |f| f << src }
			end
			require parser_path
			Rpdf2txt._text_parser
		end
		module_function :text_parser
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rpdf2txt-0.8.4 lib/rpdf2txt/textparser.rb
rpdf2txt-0.8.3 lib/rpdf2txt/textparser.rb
rpdf2txt-0.8.2 lib/rpdf2txt/textparser.rb