lib/podoff.rb in podoff-1.2.2 vs lib/podoff.rb in podoff-1.2.3

- old
+ new

@@ -1,37 +1,14 @@ -#-- -# Copyright (c) 2015-2017, John Mettraux, jmettraux@gmail.com -# -# 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. -# -# Made in Japan. -#++ require 'zlib' require 'strscan' require 'stringio' module Podoff - VERSION = '1.2.2' + VERSION = '1.2.3' def self.load(path, encoding) Podoff::Document.load(path, encoding) end @@ -85,11 +62,11 @@ @version = @scanner.scan(/%PDF-\d+\.\d+/) loop do - i = @scanner.skip_until( + @scanner.skip_until( /(startxref\s+\d+|\d+\s+\d+\s+obj|\/Root\s+\d+\s+\d+\s+R)/) m = @scanner.matched break unless m @@ -105,11 +82,11 @@ end if @root == nil @scanner.pos = 0 loop do - i = @scanner.skip_until(/\/Root\s+\d+\s+\d+\s+R/) + @scanner.skip_until(/\/Root\s+\d+\s+\d+\s+R/) break unless @scanner.matched @root = extract_ref(@scanner.matched) end end end @@ -520,10 +497,11 @@ def initialize(obj=nil) @obj = obj @font = nil + @color = nil @content = StringIO.new end def tf(font_name, font_size) @@ -531,14 +509,22 @@ @font = "/#{n} #{font_size} Tf " end alias :font :tf + def rg(red, green, blue) + + @color = "#{red} #{green} #{blue} rg " + end + alias :color :rg + alias :rgb :rg + def bt(x, y, text) @content.write "\n" if @content.size > 0 @content.write "BT " @content.write @font if @font + @content.write @color if @color @content.write "#{x} #{y} Td (#{escape(text)}) Tj" @content.write " ET" end alias :text :bt