pdf-inspector 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +77 -0
  3. data/lib/pdf/inspector/text.rb +6 -1
  4. metadata +21 -20
  5. data/README +0 -51
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb6eb253a91e8ff36b997bd9dbbeee5b5998720a
4
- data.tar.gz: 001088cf48ae54511916add5ca2f48c6d2b737c1
3
+ metadata.gz: dabf95a36af58cb71a45c659d5fa6fdf21075809
4
+ data.tar.gz: 3bdfc5a053eeeb8494501ba724735bec6a702358
5
5
  SHA512:
6
- metadata.gz: 091a699f8660b75c6519987629827e35a3fe481eda8a1621e82a3130f8fa358799b2879f79b90a3e4ee179b0a8b3bba68fd4ea6f01d9059013b6f194871696a4
7
- data.tar.gz: cc45802be0d29571bf5c956346b610f85505eca090d4fe0f533a8619eec3e917ebf32b52fd8441cd6e1aa7608777cd15be0737c6cfc8a3782286d9cab594f59e
6
+ metadata.gz: efe1848c66934975ab7d54b353ac1890a229fc67df66e6473d004063f2ac942af70a1324e9f69d9967a652b64982e40969b1cfe02f11591ae044d6135caf1312
7
+ data.tar.gz: ffcd477588f84cf79a34b13965fb2b25e401b27e32854abbee79c0344e6b1453437467d6732ae173c840cb493a4091cba17dea2c463e547a9b3e3b8f15ce48dd
@@ -0,0 +1,77 @@
1
+ # PDF::Inspector : A tool for analyzing PDF output
2
+
3
+ This library provides a number of [PDF::Reader][0] based tools for use in testing
4
+ PDF output. Presently, the primary purpose of this tool is to support the
5
+ tests found in [Prawn][1], a pure Ruby PDF generation library.
6
+
7
+ However, it may be useful to others, so we have made it available as a gem in
8
+ its own right.
9
+
10
+ ## Installation
11
+
12
+ The recommended installation method is via Rubygems.
13
+
14
+ ```ruby
15
+ gem install pdf-inspector
16
+ ```
17
+
18
+ Or put this in your Gemfile, if you use [Bundler][2]:
19
+
20
+ ```ruby
21
+ group :test do
22
+ gem 'pdf-inspector', :require => "pdf/inspector"
23
+ end
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ Check for text in the generated PDF:
29
+
30
+ ```ruby
31
+ rendered_pdf = your_pdf_document.render
32
+ text_analysis = PDF::Inspector::Text.analyze(rendered_pdf)
33
+ text_analysis.strings.should include("foo")
34
+ ```
35
+
36
+ Note that ```strings``` returns an array containing one string for each text drawing operation in the PDF. As a result, sentences and paragraphs will often be returned in fragments. To test for the presence of a complete sentence or a longer string, join the array together with an operation like ```full_text = text_analysis.strings.join(" ")```.
37
+
38
+ Check number of pages
39
+
40
+ ```
41
+ rendered_pdf = your_pdf_document.render
42
+ page_analysis = PDF::Inspector::Page.analyze(rendered_pdf)
43
+ page_analysis.pages.size.should == 2
44
+ ```
45
+
46
+ ## Licensing
47
+
48
+ Matz’s terms for Ruby, GPLv2, or GPLv3. See LICENSE for details.
49
+
50
+ ## Mailing List
51
+
52
+ pdf-inspector is maintaiend as a dependency of prawn, the ruby PDF generation
53
+ library.
54
+
55
+ Any questions or feedback should be sent to the Prawn google group.
56
+
57
+ [http://groups.google.com/group/prawn-ruby][3]
58
+
59
+ ## Authorship
60
+
61
+ pdf-inspector was originally developed by Gregory Brown as part of the Prawn[1]
62
+ project. In 2010, Gregory officially handed the project off to the Prawn core
63
+ team. Currently active maintainers include Brad Ediger, Daniel Nelson, James
64
+ Healy, and Jonathan Greenberg.
65
+
66
+ You can find the full list of Github users who have at least one patch accepted
67
+ to pdf-inspector at:
68
+
69
+ [https://github.com/sandal/pdf-inspector/contributors][4]
70
+
71
+ ## References
72
+
73
+ [0]: http://github.com/yob/pdf-reader
74
+ [1]: http://github.com/sandal/prawn
75
+ [2]: http://gembundler.com/
76
+ [3]: http://groups.google.com/group/prawn-ruby
77
+ [4]: https://github.com/sandal/pdf-inspector/contributors
@@ -3,7 +3,7 @@ module PDF
3
3
  class Text < Inspector
4
4
  attr_accessor :font_settings, :size, :strings
5
5
  attr_accessor :character_spacing, :word_spacing
6
- attr_accessor :kerned, :text_rendering_mode
6
+ attr_accessor :kerned, :text_rendering_mode, :positions
7
7
 
8
8
  def initialize
9
9
  @font_settings = []
@@ -14,6 +14,7 @@ module PDF
14
14
  @word_spacing = []
15
15
  @kerned = []
16
16
  @text_rendering_mode = []
17
+ @positions = []
17
18
  end
18
19
 
19
20
  def page=(page)
@@ -29,6 +30,10 @@ module PDF
29
30
  @font_settings << { :name => @fonts[params[0]], :size => params[1] }
30
31
  end
31
32
 
33
+ def move_text_position(tx, ty)
34
+ @positions << [tx, ty]
35
+ end
36
+
32
37
  def show_text(*params)
33
38
  @kerned << false
34
39
  @strings << @state.current_font.to_utf8(params[0])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdf-inspector
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory Brown
@@ -12,20 +12,20 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-04-08 00:00:00.000000000 Z
15
+ date: 2014-10-30 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: pdf-reader
19
19
  requirement: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - ~>
21
+ - - "~>"
22
22
  - !ruby/object:Gem::Version
23
23
  version: '1.0'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
- - - ~>
28
+ - - "~>"
29
29
  - !ruby/object:Gem::Version
30
30
  version: '1.0'
31
31
  description: |
@@ -48,46 +48,47 @@ executables: []
48
48
  extensions: []
49
49
  extra_rdoc_files:
50
50
  - CHANGELOG
51
- - README
51
+ - README.md
52
52
  files:
53
- - lib/pdf/inspector.rb
54
- - lib/pdf/inspector/extgstate.rb
55
- - lib/pdf/inspector/xobject.rb
56
- - lib/pdf/inspector/page.rb
57
- - lib/pdf/inspector/text.rb
58
- - lib/pdf/inspector/graphics.rb
59
53
  - CHANGELOG
60
- - README
61
54
  - COPYING
62
- - LICENSE
63
55
  - GPLv2
64
56
  - GPLv3
57
+ - LICENSE
58
+ - README.md
59
+ - lib/pdf/inspector.rb
60
+ - lib/pdf/inspector/extgstate.rb
61
+ - lib/pdf/inspector/graphics.rb
62
+ - lib/pdf/inspector/page.rb
63
+ - lib/pdf/inspector/text.rb
64
+ - lib/pdf/inspector/xobject.rb
65
65
  homepage: https://github.com/prawnpdf/pdf-inspector
66
66
  licenses: []
67
67
  metadata: {}
68
68
  post_install_message:
69
69
  rdoc_options:
70
- - --title
70
+ - "--title"
71
71
  - PDF::Inspector
72
- - --main
73
- - README
74
- - -q
72
+ - "--main"
73
+ - README.md
74
+ - "-q"
75
75
  require_paths:
76
76
  - lib
77
77
  required_ruby_version: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - '>='
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  requirements:
84
- - - '>='
84
+ - - ">="
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
87
  requirements: []
88
88
  rubyforge_project:
89
- rubygems_version: 2.0.0
89
+ rubygems_version: 2.2.2
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: A tool for analyzing PDF output
93
93
  test_files: []
94
+ has_rdoc:
data/README DELETED
@@ -1,51 +0,0 @@
1
- PDF::Inspector : A tool for analyzing PDF output
2
-
3
- This library provides a number of PDF::Reader[0] based tools for use in testing
4
- PDF output. Presently, the primary purpose of this tool is to support the
5
- tests found in Prawn[1], a pure Ruby PDF generation library.
6
-
7
- However, it may be useful to others, so we have made it available as a gem in
8
- its own right.
9
-
10
- = Installation
11
-
12
- The recommended installation method is via Rubygems.
13
-
14
- gem install pdf-inspector
15
-
16
- Or put this in your Gemfile, if you use Bundler[2]:
17
-
18
- group :test do
19
- gem 'pdf-inspector', :require => "pdf/inspector"
20
- end
21
-
22
- = Licensing
23
-
24
- Matz’s terms for Ruby, GPLv2, or GPLv3. See LICENSE for details.
25
-
26
- = Mailing List
27
-
28
- pdf-inspector is maintaiend as a dependency of prawn, the ruby PDF generation
29
- library.
30
-
31
- Any questions or feedback should be sent to the Prawn google group.
32
-
33
- http://groups.google.com/group/prawn-ruby
34
-
35
- = Authorship
36
-
37
- pdf-inspector was originally developed by Gregory Brown as part of the Prawn[1]
38
- project. In 2010, Gregory officially handed the project off to the Prawn core
39
- team. Currently active maintainers include Brad Ediger, Daniel Nelson, James
40
- Healy, and Jonathan Greenberg.
41
-
42
- You can find the full list of Github users who have at least one patch accepted
43
- to pdf-inspector at:
44
-
45
- https://github.com/sandal/pdf-inspector/contributors
46
-
47
- = References
48
-
49
- [0] http://github.com/yob/pdf-reader
50
- [1] http://github.com/sandal/prawn
51
- [2] http://gembundler.com/