Class: DragonflyPdf::Analysers::PdfProperties
- Inherits:
-
Object
- Object
- DragonflyPdf::Analysers::PdfProperties
- Defined in:
- lib/dragonfly_pdf/analysers/pdf_properties.rb
Constant Summary collapse
- NUMBER_OF_PAGES_REGEX =
/NumberOfPages:\s*(\d+)/
- PAGE_MEDIA_NUMBER_REGEX =
/PageMediaNumber:\s*(\d+)/
- PAGE_MEDIA_DIMENSIONS_REGEX =
/PageMediaDimensions:\s*(\d+\,?\d+\.?\d+)\s*(\d+\,?\d+\.?\d+)/
- PAGE_MEDIA_ROTATIONS_REGEX =
/PageMediaRotation:\s*(\d+)/
Instance Method Summary collapse
Instance Method Details
#call(content, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dragonfly_pdf/analysers/pdf_properties.rb', line 9 def call(content, = {}) return {} unless content.ext return {} unless SUPPORTED_FORMATS.include?(content.ext.downcase) data = `pdftk "#{content.path}" dump_data` page_count = extract_page_count(data) page_numbers = extract_page_numbers(data) page_dimensions = extract_page_dimensions(data) page_rotations = extract_page_rotations(data) aspect_ratios = calculate_aspect_ratios(page_dimensions) { 'aspect_ratios' => aspect_ratios, 'format' => content.ext.downcase, 'page_count' => page_count, 'page_dimensions' => page_dimensions, 'page_numbers' => page_numbers, 'page_rotations' => page_rotations, } end |