Class: DocumentToRichHtml::PdfConverter
- Inherits:
-
Object
- Object
- DocumentToRichHtml::PdfConverter
- Defined in:
- lib/document_to_rich_html/pdf_converter.rb
Class Method Summary collapse
Class Method Details
.convert(file_path) ⇒ Object
7 8 9 10 |
# File 'lib/document_to_rich_html/pdf_converter.rb', line 7 def self.convert(file_path) content = extract_content(file_path) HtmlFormatter.format(content) end |
.extract_content(file_path) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/document_to_rich_html/pdf_converter.rb', line 12 def self.extract_content(file_path) reader = PDF::Reader.new(file_path) html = '' reader.pages.each do |page| html += "<div class='pdf-page'>" html += page.text.split("\n").map { |line| "<p>#{line}</p>" }.join html += '</div>' end html end |