Sha256: 508c6359720cbf9913994ce8b9237f4cf66194013f72438885455a8959bd39bc

Contents?: true

Size: 1.29 KB

Versions: 46

Compression:

Stored size: 1.29 KB

Contents

class TestPage < Test::Unit::TestCase
  def test_get_image
    omit("We don't have PDF that has image...")
    document = Poppler::Document.new(image_pdf)
    page, mapping = find_first_image_mapping(document)
    assert_kind_of(Cairo::ImageSurface, page.get_image(mapping.image_id))
    assert_kind_of(Cairo::ImageSurface, mapping.image)
  end

  def test_selection_region
    document = Poppler::Document.new(form_pdf)
    page = document[0]
    rectangle = Poppler::Rectangle.new(0, 0, *page.size)
    region = page.get_selection_region(0.5, :word, rectangle)
    if later_version?(0, 7, 2)
      assert_kind_of(Poppler::Rectangle, region[0])
    else
      assert_kind_of(Gdk::Region, region)
    end
  end

  def test_annotation_mapping
    only_poppler_version(0, 7, 2)
    document = Poppler::Document.new(form_pdf)
    page = document[0]
    assert_equal([Poppler::AnnotationMapping],
                 page.annotation_mapping.collect {|mapping| mapping.class}.uniq)
    mapping = page.annotation_mapping[0]
    assert_kind_of(Poppler::Rectangle, mapping.area)
    assert_kind_of(Poppler::Annotation, mapping.annotation)
  end

  private
  def find_first_image_mapping(document)
    document.each do |page|
      page.image_mapping.each do |mapping|
        return [page, mapping]
      end
    end
    nil
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
poppler-3.0.8-x86-mingw32 test/test_page.rb
poppler-3.0.8-x64-mingw32 test/test_page.rb
poppler-3.0.8 test/test_page.rb
poppler-3.0.7-x64-mingw32 test/test_page.rb
poppler-3.0.7-x86-mingw32 test/test_page.rb
poppler-3.0.7 test/test_page.rb
poppler-3.0.6-x64-mingw32 test/test_page.rb
poppler-3.0.6-x86-mingw32 test/test_page.rb
poppler-3.0.6 test/test_page.rb
poppler-3.0.5-x64-mingw32 test/test_page.rb
poppler-3.0.5-x86-mingw32 test/test_page.rb
poppler-3.0.5 test/test_page.rb
poppler-3.0.4-x64-mingw32 test/test_page.rb
poppler-3.0.4-x86-mingw32 test/test_page.rb
poppler-3.0.4 test/test_page.rb
poppler-3.0.3-x64-mingw32 test/test_page.rb
poppler-3.0.3-x86-mingw32 test/test_page.rb
poppler-3.0.3 test/test_page.rb
poppler-3.0.2-x64-mingw32 test/test_page.rb
poppler-3.0.2-x86-mingw32 test/test_page.rb