class PrawnHtml::Tags::Img
def adjust_styles(pdf, img_styles)
def adjust_styles(pdf, img_styles) {}.tap do |result| w, h = img_styles['width'], img_styles['height'] result[:width] = Utils.convert_size(w, options: pdf.page_width) if w result[:height] = Utils.convert_size(h, options: pdf.page_height) if h result[:position] = img_styles[:align] if %i[left center right].include?(img_styles[:align]) end end
def block?
def block? true end
def custom_render(pdf, context)
def custom_render(pdf, context) parsed_styles = Attributes.parse_styles(attrs.style) block_styles = context.block_styles evaluated_styles = adjust_styles(pdf, block_styles.merge(parsed_styles)) pdf.image(@attrs.src, evaluated_styles) end