From: Kouhei S. <nu...@co...> - 2017-08-06 15:14:09
|
Kouhei Sutou 2017-08-07 00:13:37 +0900 (Mon, 07 Aug 2017) New Revision: 0bc8828e29201ed01d27ad3760c5613ae699dfc7 https://github.com/ruby-gnome2/ruby-gnome2/commit/0bc8828e29201ed01d27ad3760c5613ae699dfc7 Message: poppler: support Page#text_layout Added files: poppler/lib/poppler/page.rb poppler/lib/poppler/rectangle.rb Modified files: poppler/lib/poppler/loader.rb Modified: poppler/lib/poppler/loader.rb (+2 -0) =================================================================== --- poppler/lib/poppler/loader.rb 2017-08-07 00:12:46 +0900 (d4cc7bafd) +++ poppler/lib/poppler/loader.rb 2017-08-07 00:13:37 +0900 (798ec8f31) @@ -33,6 +33,8 @@ module Poppler require "poppler/cairo" require "poppler/color" require "poppler/document" + require "poppler/page" + require "poppler/rectangle" require "poppler/deprecated" end Added: poppler/lib/poppler/page.rb (+29 -0) 100644 =================================================================== --- /dev/null +++ poppler/lib/poppler/page.rb 2017-08-07 00:13:37 +0900 (158d4a902) @@ -0,0 +1,29 @@ +# Copyright (C) 2017 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +module Poppler + class Page + alias_method :text_layout_raw, :text_layout + def text_layout + success, rectangles = text_layout_raw + if success + rectangles + else + nil + end + end + end +end Added: poppler/lib/poppler/rectangle.rb (+29 -0) 100644 =================================================================== --- /dev/null +++ poppler/lib/poppler/rectangle.rb 2017-08-07 00:13:37 +0900 (dbf2c1d9f) @@ -0,0 +1,29 @@ +# Copyright (C) 2017 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +module Poppler + class Rectangle + def to_a + [x1, y1, x2, y2] + end + + def inspect + super.gsub(/>\z/) do + ": [%g, %g, %g, %g]>" % to_a + end + end + end +end |