Module: OnlyofficePdfParser::PdfReaderHelper

Included in:
PdfStructure
Defined in:
lib/onlyoffice_pdf_parser/pdf_structure/pdf_reader_helper.rb

Overview

Module for helper methods for ‘pdf-reader` gem

Instance Method Summary collapse

Instance Method Details

#parse_font(page) ⇒ String

Return font name from page data

Parameters:

  • page (PDF::Reader::Page)

    page to parse

Returns:

  • (String)

    font



9
10
11
12
13
14
15
# File 'lib/onlyoffice_pdf_parser/pdf_structure/pdf_reader_helper.rb', line 9

def parse_font(page)
  return :unknown if page.fonts[:F1].nil?

  font_string = page.fonts[:F1][:BaseFont].to_s
  font_string = /(?=\+)(.*)/.match(font_string).to_s # remove from "+" to ","
  font_string.delete('+')
end