I ended up using the :callback option for formatted_text_box.
class CustomUnderlineCallback
def initialize(options)
@document = options[:document]
end
def render_in_front(fragment)
@document.stroke_color COLOR_WHITE
@document.stroke_polygon fragment.bottom_left, fragment.bottom_right
@document.stroke_color COLOR_BLACK
end
end