diff --git a/lib/prawn/table.rb b/lib/prawn/table.rb index 718fe69..9809559 100644 --- a/lib/prawn/table.rb +++ b/lib/prawn/table.rb @@ -15,6 +15,7 @@ require_relative 'table/cell/text' require_relative 'table/cell/subtable' require_relative 'table/cell/image' +require_relative 'table/cell/svg' require_relative 'table/cell/span_dummy' module Prawn diff --git a/lib/prawn/table/cell.rb b/lib/prawn/table/cell.rb index 3dbbc84..69c1bd8 100644 --- a/lib/prawn/table/cell.rb +++ b/lib/prawn/table/cell.rb @@ -163,6 +163,7 @@ def self.make(pdf, content, options={}) at = options.delete(:at) || [0, pdf.cursor] return Cell::Image.new(pdf, at, content) if content.is_a?(Hash) && content[:image] + return Cell::SVG.new(pdf, at, content) if content.is_a?(Hash) && content[:svg] if content.is_a?(Hash) options.update(content) diff --git a/lib/prawn/table/cell/svg.rb b/lib/prawn/table/cell/svg.rb new file mode 100644 index 0000000..5135e01 --- /dev/null +++ b/lib/prawn/table/cell/svg.rb @@ -0,0 +1,76 @@ +# encoding: utf-8 + +# image.rb: Table image cells. +# +# Copyright September 2010, Brad Ediger. All Rights Reserved. +# +# This is free software. Please see the LICENSE and COPYING files for details. +module Prawn + class Table + class Cell + # @private + class SVG < Cell + def initialize(pdf, point, options={}) + @svg_options = options + + super + + + # @pdf_object, @image_info = @pdf.build_image_object(@file) + # @natural_width, @natural_height = @image_info.calc_image_dimensions( + # @image_options) + end + + def svg=(file) + @file = file + end + + def svg_width=(width) + @svg_width = width + end + + def svg_height=(height) + @svg_height = height + end + + # def scale=(s) + # @image_options[:scale] = s + # end + + # def fit=(f) + # @image_options[:fit] = f + # end + + # def image_height=(h) + # @image_options[:height] = h + # end + + # def image_width=(w) + # @image_options[:width] = w + # end + + # def position=(p) + # @image_options[:position] = p + # end + + # def vposition=(vp) + # @image_options[:vposition] = vp + # end + + def natural_content_width + @svg_width + end + + def natural_content_height + @svg_height + end + + # Embed the SVG on the page + # + def draw_content + @pdf.svg File.read(@file), width: @svg_width, height: @svg_height + end + end + end + end +end