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
487 488 489 |
# File 'lib/kramdown/converter/pdf.rb', line 487 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.
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
# File 'lib/kramdown/converter/pdf.rb', line 494 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[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(sprintf(instruct, w, h, x, y - h, label)) end |
#image_floats ⇒ Object
489 490 491 |
# File 'lib/kramdown/converter/pdf.rb', line 489 def image_floats @image_floats ||= [] end |