README.md in prawn-svg-0.22.1 vs README.md in prawn-svg-0.23.0

- old
+ new

@@ -5,36 +5,52 @@ An SVG renderer for the Prawn PDF library. This will take an SVG file as input and render it into your PDF. Find out more about the Prawn PDF library at: - http://wiki.github.com/sandal/prawn/ + http://github.com/prawnpdf/prawn prawn-svg is compatible with all versions of Prawn from 0.11.1 onwards, including the 1.x and 2.x series. The minimum Ruby version required is 2.0.0. ## Using prawn-svg ```ruby -Prawn::Document.generate("svg.pdf") do - svg svg_data, :at => [x, y], :width => w +Prawn::Document.generate("test.pdf") do + svg '<svg><rect width="100" height="100" fill="red"></rect></svg>' end ``` -Supply <tt>:at</tt> if you want to render it at a specific location on the page. -Use <tt>:position</tt> with a value of <tt>:left</tt>, <tt>:center</tt>, <tt>:right</tt> or a number to render it at the current cursor position, or use <tt>:vposition</tt> with a value -of <tt>:top</tt>, <tt>:center</tt>, <tt>:bottom</tt> or a number to specify its Y position too. +prawn-svg will do something sensible if you call it with only an SVG document, but you can also +pass the following options to tailor its operation: -Either <tt>:width</tt>, <tt>:height</tt>, or neither may be specified; if neither is present, -the dimensions specified in the SVG will be used, or if the dimensions aren't specified, it'll -fit to the space available on the page. +Option | Data type | Description +----------- | --------- | ----------- +:at | [integer, integer] | Specify the location on the page you want the SVG to appear. +:position | :left, :center, :right, integer | If :at not specified, specifies the horizontal position to show the SVG. Defaults to :left. +:vposition | :top, :center, :bottom, integer | If :at not specified, specifies the vertical position to show the SVG. Defaults to current cursor position. +:width | integer | Desired width of the SVG. Defaults to horizontal space available. +:height | integer | Desired height of the SVG. Defaults to vertical space available. +:enable_web_requests | boolean | If true, prawn-svg will make http and https requests to fetch images. Defaults to true. +:enable_file_requests_with_root | string | If not nil, prawn-svg will serve `file:` URLs from your local disk if the file is located under the specified directory. It is very dangerous to specify the root path ("/") if you're not fully in control of your input SVG. Defaults to `nil` (off). +:cache_images | boolean | If true, prawn-svg will cache the result of all URL requests. Defaults to false. +:fallback_font_name | string | A font name which will override the default fallback font of Times-Roman. If this value is set to <tt>nil</tt>, prawn-svg will ignore a request for an unknown font and log a warning. -<tt>:cache_images</tt>, if set to true, will cache images per document based on their URL. +## Examples -<tt>:fallback_font_name</tt> takes a font name which will override the default fallback font of Times-Roman. -If this value is set to <tt>nil</tt>, prawn-svg will ignore a request for an unknown font and log a warning. +```ruby + # Render the logo contained in the file logo.svg at 100, 100 with a width of 300 + svg IO.read("logo.svg"), at: [100, 100], width: 300 + # Render the logo at the current Y cursor position, centered in the current bounding box + svg IO.read("logo.svg"), position: :center + + # Render the logo at the current Y cursor position, and serve file: links relative to its directory + root_path = "/apps/myapp/current/images" + svg IO.read("#{root_path}/logo.svg"), enable_file_requests_with_root: root_path +``` + ## Supported features prawn-svg supports most but not all of the full SVG 1.1 specification. It currently supports: - <tt>&lt;line&gt;</tt>, <tt>&lt;polyline&gt;</tt>, <tt>&lt;polygon&gt;</tt>, <tt>&lt;circle&gt;</tt> and <tt>&lt;ellipse&gt;</tt> @@ -88,10 +104,10 @@ By default, prawn-svg has a fonts path of <tt>["/Library/Fonts", "/System/Library/Fonts", "#{ENV["HOME"]}/Library/Fonts", "/usr/share/fonts/truetype"]</tt> to catch Mac OS X and Debian Linux users. You can add to the font path: ```ruby - Prawn::SVG::Interface.font_path << "/my/font/directory" + Prawn::SVG::FontRegistry.font_path << "/my/font/directory" ``` -- Copyright Roger Nesbitt <roger@seriousorange.com>. MIT licence.