Sablon.Content.Image (sablon v0.4.3)

Copy Markdown View Source

Image insertion.

An image replaces a placeholder picture wrapped in a pair of «@name:start» / «@name:end» merge fields. The image data is added to word/media, a relationship is created for every document part that uses it, and the placeholder keeps its size unless :width and :height are given.

Sources may be a path, an http(s) URL, or raw data as {:data, binary} together with a :filename option - a filename is required so Word can derive the content type.

Summary

Functions

The height of the image in EMU, or nil when it keeps the placeholder's.

Reads an image from source.

Converts a cm or in dimension string into Word's EMU units.

The width of the image in EMU, or nil when it keeps the placeholder's.

Types

t()

@type t() :: %Sablon.Content.Image{
  attributes: map(),
  data: binary(),
  local_rid: binary() | nil,
  name: binary(),
  properties: map(),
  ref: reference()
}

Functions

height(image)

@spec height(t()) :: integer() | nil

The height of the image in EMU, or nil when it keeps the placeholder's.

new(source, options \\ [])

@spec new(term(), keyword() | map()) :: t()

Reads an image from source.

Options: :filename (required for raw data), :properties with :width and :height given in cm or in.

to_emu(dimension)

@spec to_emu(binary()) :: integer()

Converts a cm or in dimension string into Word's EMU units.

width(image)

@spec width(t()) :: integer() | nil

The width of the image in EMU, or nil when it keeps the placeholder's.