pax_global_header00006660000000000000000000000064151554555340014526gustar00rootroot0000000000000052 comment=98d5f7a943a4e33821541e5f6347bef42bb96e26 mogest-prawn-svg-98d5f7a/000077500000000000000000000000001515545553400153775ustar00rootroot00000000000000mogest-prawn-svg-98d5f7a/.github/000077500000000000000000000000001515545553400167375ustar00rootroot00000000000000mogest-prawn-svg-98d5f7a/.github/workflows/000077500000000000000000000000001515545553400207745ustar00rootroot00000000000000mogest-prawn-svg-98d5f7a/.github/workflows/lint.yml000066400000000000000000000005141515545553400224650ustar00rootroot00000000000000name: RuboCop on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: 3.3 bundler-cache: true - name: Run RuboCop run: bundle exec rubocop --parallel mogest-prawn-svg-98d5f7a/.github/workflows/test.yml000066400000000000000000000010421515545553400224730ustar00rootroot00000000000000name: test on: [push, pull_request] jobs: test: runs-on: ubuntu-latest strategy: fail-fast: false matrix: ruby: [2.7, '3.0', 3.1, 3.2, 3.3] steps: - uses: actions/checkout@v4 - name: Remove Gemfile.lock run: rm -f Gemfile.lock - name: Set up Ruby uses: ruby/setup-ruby@v1 with: bundler-cache: true ruby-version: ${{ matrix.ruby }} - name: Run tests run: bundle exec rake env: RUBYOPT: "--enable-frozen-string-literal" mogest-prawn-svg-98d5f7a/.gitignore000066400000000000000000000002311515545553400173630ustar00rootroot00000000000000.DS_Store spec/sample_output/*.pdf spec/sample_ttf/NotoSansJP-Regular.ttf prawn-svg-*.gem .rvmrc .*.swp .ruby-version vendor/bundle/ .bundle/ .mise.toml mogest-prawn-svg-98d5f7a/.rspec000066400000000000000000000000371515545553400165140ustar00rootroot00000000000000--format documentation --color mogest-prawn-svg-98d5f7a/.rubocop.yml000066400000000000000000000024041515545553400176510ustar00rootroot00000000000000inherit_from: .rubocop_todo.yml AllCops: TargetRubyVersion: 2.7 NewCops: enable Metrics/AbcSize: Enabled: false Metrics/BlockLength: Enabled: false Metrics/ClassLength: Enabled: false Metrics/CyclomaticComplexity: Enabled: false Metrics/MethodLength: Enabled: false Metrics/ModuleLength: Enabled: false Metrics/PerceivedComplexity: Enabled: false Style/Documentation: Enabled: false Style/FrozenStringLiteralComment: Enabled: false Style/ClassAndModuleChildren: Enabled: false Style/GuardClause: Enabled: false Style/SymbolArray: Enabled: false Style/WordArray: Enabled: false Layout/HashAlignment: EnforcedHashRocketStyle: table EnforcedColonStyle: table Layout/FirstArgumentIndentation: EnforcedStyle: consistent Layout/ArgumentAlignment: EnforcedStyle: with_fixed_indentation Lint/SuppressedException: Enabled: false Style/AccessorGrouping: Enabled: false Style/PerlBackrefs: Enabled: false Naming/MethodParameterName: Enabled: false Metrics/ParameterLists: Enabled: false Metrics/BlockNesting: Enabled: false Naming/VariableNumber: Enabled: false Lint/ConstantDefinitionInBlock: Exclude: - spec/**/*.rb Style/GlobalVars: Exclude: - spec/**/*.rb Style/MultilineBlockChain: Enabled: false mogest-prawn-svg-98d5f7a/.rubocop_todo.yml000066400000000000000000000036101515545553400206760ustar00rootroot00000000000000# This configuration was generated by # `rubocop --auto-gen-config` # on 2024-06-16 03:19:10 UTC using RuboCop version 1.62.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. # Offense count: 1 # Configuration parameters: AllowComments, AllowEmptyLambdas. Lint/EmptyBlock: Exclude: - 'Rakefile' # Offense count: 13 Lint/NonLocalExitFromIterator: Exclude: - 'lib/prawn/svg/css/selector_parser.rb' - 'lib/prawn/svg/ttf.rb' # Offense count: 1 Naming/AccessorMethodName: Exclude: - 'lib/prawn/svg/calculators/document_sizing.rb' # Offense count: 1 # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms. # CheckDefinitionPathHierarchyRoots: lib, spec, test, src # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS Naming/FileName: Exclude: - 'lib/prawn-svg.rb' # Offense count: 9 # This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: Exclude: - 'lib/prawn/svg/css/selector_parser.rb' - 'lib/prawn/svg/elements/base.rb' - 'lib/prawn/svg/elements/gradient.rb' - 'lib/prawn/svg/elements/root.rb' - 'lib/prawn/svg/elements/text_component.rb' - 'lib/prawn/svg/elements/use.rb' - 'lib/prawn/svg/loaders/file.rb' # Offense count: 28 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https Layout/LineLength: Max: 180 mogest-prawn-svg-98d5f7a/Gemfile000066400000000000000000000010671515545553400166760ustar00rootroot00000000000000source 'http://rubygems.org' # Declare your gem's dependencies in prawn-svg.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec # Declare any dependencies that are still in development here instead of in # your gemspec. These might include edge Rails or gems from your path or # Git. Remember to move these dependencies to your gemspec before releasing # your gem to rubygems.org. gem 'rake', '~> 13.0' gem 'rspec', '~> 3.0' gem 'rubocop', '~> 1.64' mogest-prawn-svg-98d5f7a/Gemfile.lock000066400000000000000000000033471515545553400176300ustar00rootroot00000000000000PATH remote: . specs: prawn-svg (0.40.0) css_parser (~> 1.6) matrix (~> 0.4.2) prawn (>= 0.11.1, < 3) rexml (>= 3.4.2, < 4) GEM remote: http://rubygems.org/ specs: addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) bigdecimal (3.1.8) css_parser (1.17.1) addressable diff-lcs (1.5.1) json (2.7.2) language_server-protocol (3.17.0.3) matrix (0.4.2) parallel (1.25.1) parser (3.3.3.0) ast (~> 2.4.1) racc pdf-core (0.10.0) prawn (2.5.0) matrix (~> 0.4) pdf-core (~> 0.10.0) ttfunk (~> 1.8) public_suffix (5.1.0) racc (1.8.0) rainbow (3.1.1) rake (13.2.1) regexp_parser (2.9.2) rexml (3.4.4) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) rspec-core (3.13.0) rspec-support (~> 3.13.0) rspec-expectations (3.13.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-support (3.13.1) rubocop (1.64.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.31.3) parser (>= 3.3.1.0) ruby-progressbar (1.13.0) ttfunk (1.8.0) bigdecimal (~> 3.1) unicode-display_width (2.5.0) PLATFORMS ruby DEPENDENCIES prawn-svg! rake (~> 13.0) rspec (~> 3.0) rubocop (~> 1.64) BUNDLED WITH 2.5.1 mogest-prawn-svg-98d5f7a/LICENSE000066400000000000000000000020631515545553400164050ustar00rootroot00000000000000The MIT License Copyright 2010-2019 Roger Nesbitt Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. mogest-prawn-svg-98d5f7a/README.md000066400000000000000000000213171515545553400166620ustar00rootroot00000000000000# prawn-svg [![Gem Version](https://badge.fury.io/rb/prawn-svg.svg)](https://badge.fury.io/rb/prawn-svg) ![Build Status](https://github.com/mogest/prawn-svg/actions/workflows/test.yml/badge.svg?branch=main) An SVG renderer for the [Prawn PDF library](https://github.com/prawnpdf/prawn). This will take an SVG document as input and render it into your PDF, along with whatever else you build with Prawn. prawn-svg is compatible with all versions of Prawn from 0.11.1 onwards, including the 1.x and 2.x series, although you'll need version 2.2.0 onwards if you want color gradients. The minimum Ruby version required is 2.7. ## Using prawn-svg ```ruby Prawn::Document.generate("test.pdf") do svg '' end ``` 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: 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, `@font-face` fonts, and external `` references.

Defaults to true, but will **default to false** in the upcoming 1.0 release. It's recommended you explicitly set this option for now. :enable_file_requests_with_root | string | If not nil, prawn-svg will serve `file:` URLs and relative paths from your local disk if the file is located under the specified directory. Required for `@font-face` fonts and external `` references loaded via file paths.

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 `nil`, prawn-svg will ignore a request for an unknown font and log a warning. :color_mode | :rgb, :cmyk | Output color mode. Defaults to :rgb. :language | string | BCP 47 language tag for `` `systemLanguage` matching. Defaults to `"en"`. :log_warnings | boolean | If true, warnings that occur when parsing/rendering the SVG are output to stderr via `warn`. Use this when you're not getting the output you expect. Defaults to false. ## Examples ```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, log_warnings: true ``` ## Supported features prawn-svg supports almost all of the full SVG 1.1 specification: - ``, ``, ``, ``, `` and `` - `` - ``, ``, `` and `` with attributes `x`, `y`, `dx`, `dy`, `rotate`, `textLength`, `lengthAdjust`, and with extra properties `text-anchor`, `text-decoration`, `font`, `font-size`, `font-family`, `font-weight`, `font-style`, `font-stretch`, `kerning`, `letter-spacing`, `word-spacing`, `dominant-baseline`, `alignment-baseline`, `baseline-shift`. `` supports `href`/`xlink:href` and `startOffset`. - ``, `` and `` - `` with local and external references (e.g. `other.svg#elementId`), subject to `enable_web_requests` and `enable_file_requests_with_root` - `