Module: Kramdown::Converter::Pdf::PrawnDocumentExtension
- Defined in:
- lib/kramdown/converter/pdf.rb
Overview
This module gets mixed into the Prawn::Document instance.
Defined Under Namespace
Modules: CustomBox
Instance Attribute Summary collapse
-
#converter ⇒ Object
Access the converter instance from within Prawn.
Instance Method Summary collapse
-
#embed_image(pdf_obj, info, options) ⇒ Object
Override image embedding method for adding image positions to #image_floats.
- #image_floats ⇒ Object
Instance Attribute Details
#converter ⇒ Object
Access the converter instance from within Prawn
477 478 479 |
# File 'lib/kramdown/converter/pdf.rb', line 477 def converter @converter end |
Instance Method Details
#embed_image(pdf_obj, info, options) ⇒ Object
Override image embedding method for adding image positions to #image_floats.
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
# File 'lib/kramdown/converter/pdf.rb', line 484 def (pdf_obj, info, ) # find where the image will be placed and how big it will be w,h = info.calc_image_dimensions() if [:at] x,y = map_to_absolute([:at]) else x,y = image_position(w,h,) move_text_position h end #--> This part is new if [:position] == :right image_floats << [page_number, x - 15, y, w + 15, h + 15] end # add a reference to the image object to the current page # resource list and give it a label label = "I#{next_image_id}" state.page.xobjects.merge!(label => pdf_obj) # add the image to the current page instruct = "\nq\n%.3f 0 0 %.3f %.3f %.3f cm\n/%s Do\nQ" add_content instruct % [ w, h, x, y - h, label ] end |
#image_floats ⇒ Object
479 480 481 |
# File 'lib/kramdown/converter/pdf.rb', line 479 def image_floats @image_floats ||= [] end |