Module: Kramdown::Converter::Pdf::PrawnDocumentExtension::CustomBox

Defined in:
lib/kramdown/converter/pdf.rb

Overview

Extension for the formatted box class to recognize images and move text around them.

Instance Method Summary collapse

Instance Method Details

#available_widthObject



467
468
469
470
471
472
473
474
475
476
477
478
479
480
# File 'lib/kramdown/converter/pdf.rb', line 467

def available_width
  return super unless @document.respond_to?(:converter) && @document.converter

  @document.image_floats.each do |pn, _x, y, w, h|
    next if @document.page_number != pn
    if @at[1] + @baseline_y <= y - @document.bounds.absolute_bottom &&
        (@at[1] + @baseline_y + @arranger.max_line_height +
         @leading >= y - h - @document.bounds.absolute_bottom)
      return @width - w
    end
  end

  super
end