Sha256: 20ea86b93b575bc5ad1e74567bb9dc0d4d6e45773033a880054fa09745ad7a29

Contents?: true

Size: 737 Bytes

Versions: 1

Compression:

Stored size: 737 Bytes

Contents

require File.dirname(__FILE__) + "/../../node/base"
require "PDFlib"
module FN
  module PDF
    module Node
      def FitImage(image, x, y, opts = {})
        if opts.delete(:inverted)
          opts[:orientate] = "south"
        end
        FN::Node::Base("fit_image", opts.merge(:image => image, :x => x, :y => y)).extend(FitImage)
      end
      
      module FitImage 
        include FN::Node::Base
      
        def visit(struct)
          has_no_children
          h = attributes.to_h
          img = struct[h.delete("image")]
          x = h.delete("x").to_i
          y = h.delete("y").to_i
          h["scale"] = 0.99 # if h["scale"] == "1.0"  
          struct.fit_image(img, x, y, h)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fn_document-0.9.2 lib/fn/pdf/node/fit_image.rb