Class: Consolidate::Docx::Image

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/consolidate/docx/image.rb

Constant Summary collapse

DEFAULT_PAGE_WIDTH =

Constants

12_240
TWENTIETHS_OF_A_POINT_TO_EMU =
635
DEFAULT_PAGE_WIDTH_IN_EMU =
DEFAULT_PAGE_WIDTH * TWENTIETHS_OF_A_POINT_TO_EMU
EMU_PER_PIXEL =
9525
DEFAULT_PAGE_HEIGHT =

Assuming US Letter size

DEFAULT_PAGE_WIDTH * 11 / 8.5
DEFAULT_PAGE_HEIGHT_IN_EMU =
DEFAULT_PAGE_HEIGHT * TWENTIETHS_OF_A_POINT_TO_EMU
DEFAULT_MARGIN_IN_EMU =

Common page margins in EMU (0.75 inches)

685800

Instance Method Summary collapse

Instance Method Details

#emu_per_height_pixelObject



22
# File 'lib/consolidate/docx/image.rb', line 22

def emu_per_height_pixel = EMU_PER_PIXEL * 72 / dpi[:y]

#emu_per_width_pixelObject



20
# File 'lib/consolidate/docx/image.rb', line 20

def emu_per_width_pixel = EMU_PER_PIXEL * 72 / dpi[:x]

#height_in_emuObject

Convert height from pixels to EMU with proper DPI scaling



18
# File 'lib/consolidate/docx/image.rb', line 18

def height_in_emu = height * emu_per_height_pixel

#media_pathObject

Path to use when referencing this image from other documents



9
# File 'lib/consolidate/docx/image.rb', line 9

def media_path = "media/#{name}"

#storage_pathObject

Path to use when storing this image within the docx



12
# File 'lib/consolidate/docx/image.rb', line 12

def storage_path = "word/#{media_path}"

#width_in_emuObject

Convert width from pixels to EMU with proper DPI scaling



15
# File 'lib/consolidate/docx/image.rb', line 15

def width_in_emu = width * emu_per_width_pixel