module Kramdown::Converter::Pdf::PrawnDocumentExtension

This module gets mixed into the Prawn::Document instance.

Attributes

converter[RW]

Access the converter instance from within Prawn

Public Instance Methods

embed_image(pdf_obj, info, options) click to toggle source

Override image embedding method for adding image positions to image_floats.

    # File lib/kramdown/converter/pdf.rb
483 def embed_image(pdf_obj, info, options)
484   # find where the image will be placed and how big it will be
485   w,h = info.calc_image_dimensions(options)
486 
487   if options[:at]
488     x,y = map_to_absolute(options[:at])
489   else
490     x,y = image_position(w,h,options)
491     move_text_position h
492   end
493 
494   #--> This part is new
495   if options[:position] == :right
496     image_floats << [page_number, x - 15, y, w + 15, h + 15]
497   end
498 
499   # add a reference to the image object to the current page
500   # resource list and give it a label
501   label = "I#{next_image_id}"
502   state.page.xobjects.merge!(label => pdf_obj)
503 
504   # add the image to the current page
505   instruct = "\nq\n%.3f 0 0 %.3f %.3f %.3f cm\n/%s Do\nQ"
506   add_content instruct % [ w, h, x, y - h, label ]
507 end
image_floats() click to toggle source
    # File lib/kramdown/converter/pdf.rb
478 def image_floats
479   @image_floats ||= []
480 end