pdf-inspector 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +9 -0
- data/GPLv2 +20 -21
- data/lib/pdf/inspector.rb +12 -2
- data/lib/pdf/inspector/extgstate.rb +8 -6
- data/lib/pdf/inspector/graphics.rb +4 -2
- data/lib/pdf/inspector/page.rb +15 -4
- data/lib/pdf/inspector/text.rb +15 -4
- data/lib/pdf/inspector/xobject.rb +6 -12
- metadata +42 -64
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bb6eb253a91e8ff36b997bd9dbbeee5b5998720a
|
4
|
+
data.tar.gz: 001088cf48ae54511916add5ca2f48c6d2b737c1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 091a699f8660b75c6519987629827e35a3fe481eda8a1621e82a3130f8fa358799b2879f79b90a3e4ee179b0a8b3bba68fd4ea6f01d9059013b6f194871696a4
|
7
|
+
data.tar.gz: cc45802be0d29571bf5c956346b610f85505eca090d4fe0f533a8619eec3e917ebf32b52fd8441cd6e1aa7608777cd15be0737c6cfc8a3782286d9cab594f59e
|
data/CHANGELOG
CHANGED
data/GPLv2
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
2
|
+
Version 2, June 1991
|
3
3
|
|
4
|
-
Copyright (C) 1989, 1991 Free Software Foundation, Inc
|
5
|
-
|
4
|
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
5
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6
6
|
Everyone is permitted to copy and distribute verbatim copies
|
7
7
|
of this license document, but changing it is not allowed.
|
8
8
|
|
9
|
-
|
9
|
+
Preamble
|
10
10
|
|
11
11
|
The licenses for most software are designed to take away your
|
12
12
|
freedom to share and change it. By contrast, the GNU General Public
|
@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This
|
|
15
15
|
General Public License applies to most of the Free Software
|
16
16
|
Foundation's software and to any other program whose authors commit to
|
17
17
|
using it. (Some other Free Software Foundation software is covered by
|
18
|
-
the GNU
|
18
|
+
the GNU Lesser General Public License instead.) You can apply it to
|
19
19
|
your programs, too.
|
20
20
|
|
21
21
|
When we speak of free software, we are referring to freedom, not
|
@@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all.
|
|
55
55
|
|
56
56
|
The precise terms and conditions for copying, distribution and
|
57
57
|
modification follow.
|
58
|
-
|
59
|
-
|
58
|
+
|
59
|
+
GNU GENERAL PUBLIC LICENSE
|
60
60
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61
61
|
|
62
62
|
0. This License applies to any program or other work which contains
|
@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
|
|
110
110
|
License. (Exception: if the Program itself is interactive but
|
111
111
|
does not normally print such an announcement, your work based on
|
112
112
|
the Program is not required to print an announcement.)
|
113
|
-
|
113
|
+
|
114
114
|
These requirements apply to the modified work as a whole. If
|
115
115
|
identifiable sections of that work are not derived from the Program,
|
116
116
|
and can be reasonably considered independent and separate works in
|
@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
|
|
168
168
|
access to copy the source code from the same place counts as
|
169
169
|
distribution of the source code, even though third parties are not
|
170
170
|
compelled to copy the source along with the object code.
|
171
|
-
|
171
|
+
|
172
172
|
4. You may not copy, modify, sublicense, or distribute the Program
|
173
173
|
except as expressly provided under this License. Any attempt
|
174
174
|
otherwise to copy, modify, sublicense or distribute the Program is
|
@@ -225,7 +225,7 @@ impose that choice.
|
|
225
225
|
|
226
226
|
This section is intended to make thoroughly clear what is believed to
|
227
227
|
be a consequence of the rest of this License.
|
228
|
-
|
228
|
+
|
229
229
|
8. If the distribution and/or use of the Program is restricted in
|
230
230
|
certain countries either by patents or by copyrighted interfaces, the
|
231
231
|
original copyright holder who places the Program under this License
|
@@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
|
|
255
255
|
of preserving the free status of all derivatives of our free software and
|
256
256
|
of promoting the sharing and reuse of software generally.
|
257
257
|
|
258
|
-
|
258
|
+
NO WARRANTY
|
259
259
|
|
260
260
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261
261
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
@@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
|
277
277
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278
278
|
POSSIBILITY OF SUCH DAMAGES.
|
279
279
|
|
280
|
-
|
281
|
-
|
282
|
-
|
280
|
+
END OF TERMS AND CONDITIONS
|
281
|
+
|
282
|
+
How to Apply These Terms to Your New Programs
|
283
283
|
|
284
284
|
If you develop a new program, and you want it to be of the greatest
|
285
285
|
possible use to the public, the best way to achieve this is to make it
|
@@ -303,17 +303,16 @@ the "copyright" line and a pointer to where the full notice is found.
|
|
303
303
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304
304
|
GNU General Public License for more details.
|
305
305
|
|
306
|
-
You should have received a copy of the GNU General Public License
|
307
|
-
|
308
|
-
|
309
|
-
|
306
|
+
You should have received a copy of the GNU General Public License along
|
307
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
308
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
310
309
|
|
311
310
|
Also add information on how to contact you by electronic and paper mail.
|
312
311
|
|
313
312
|
If the program is interactive, make it output a short notice like this
|
314
313
|
when it starts in an interactive mode:
|
315
314
|
|
316
|
-
Gnomovision version 69, Copyright (C) year
|
315
|
+
Gnomovision version 69, Copyright (C) year name of author
|
317
316
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
318
317
|
This is free software, and you are welcome to redistribute it
|
319
318
|
under certain conditions; type `show c' for details.
|
@@ -336,5 +335,5 @@ necessary. Here is a sample; alter the names:
|
|
336
335
|
This General Public License does not permit incorporating your program into
|
337
336
|
proprietary programs. If your program is a subroutine library, you may
|
338
337
|
consider it more useful to permit linking proprietary applications with the
|
339
|
-
library. If this is what you want to do, use the GNU
|
338
|
+
library. If this is what you want to do, use the GNU Lesser General
|
340
339
|
Public License instead of this License.
|
data/lib/pdf/inspector.rb
CHANGED
@@ -5,17 +5,27 @@ require "pdf/inspector/xobject"
|
|
5
5
|
require "pdf/inspector/extgstate"
|
6
6
|
require "pdf/inspector/graphics"
|
7
7
|
require "pdf/inspector/page"
|
8
|
+
require "stringio"
|
8
9
|
|
9
10
|
module PDF
|
10
11
|
class Inspector
|
11
12
|
def self.analyze(output,*args,&block)
|
13
|
+
if output.is_a?(String)
|
14
|
+
output = StringIO.new(output)
|
15
|
+
end
|
12
16
|
obs = self.new(*args, &block)
|
13
|
-
PDF::Reader.
|
17
|
+
PDF::Reader.open(output) do |reader|
|
18
|
+
reader.pages.each do |page|
|
19
|
+
page.walk(obs)
|
20
|
+
end
|
21
|
+
end
|
14
22
|
obs
|
15
23
|
end
|
16
24
|
|
17
25
|
def self.analyze_file(filename,*args,&block)
|
18
|
-
|
26
|
+
File.open(filename, "rb") do |io|
|
27
|
+
analyze(io, *args,&block)
|
28
|
+
end
|
19
29
|
end
|
20
30
|
|
21
31
|
def self.parse(obj)
|
@@ -7,12 +7,14 @@ module PDF
|
|
7
7
|
@extgstates = []
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
def page=(page)
|
11
|
+
page.graphic_states.each do |label, stream|
|
12
|
+
@extgstates << {
|
13
|
+
:opacity => stream[:ca],
|
14
|
+
:stroke_opacity => stream[:CA],
|
15
|
+
:soft_mask => stream[:SMask]
|
16
|
+
}
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
data/lib/pdf/inspector/page.rb
CHANGED
@@ -1,23 +1,34 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
1
3
|
module PDF
|
2
4
|
class Inspector
|
3
5
|
class Page < Inspector
|
6
|
+
extend Forwardable
|
7
|
+
|
4
8
|
attr_reader :pages
|
9
|
+
|
10
|
+
def_delegators :@state, :set_text_font_and_size
|
5
11
|
|
6
12
|
def initialize
|
7
13
|
@pages = []
|
8
14
|
end
|
9
15
|
|
10
|
-
def
|
11
|
-
@pages << {:size =>
|
16
|
+
def page=(page)
|
17
|
+
@pages << {:size => page.attributes[:MediaBox][-2..-1], :strings => []}
|
18
|
+
@state = PDF::Reader::PageState.new(page)
|
12
19
|
end
|
13
20
|
|
14
21
|
def show_text(*params)
|
15
|
-
|
22
|
+
params.each do |param|
|
23
|
+
@pages.last[:strings] << @state.current_font.to_utf8(param)
|
24
|
+
end
|
16
25
|
end
|
17
26
|
|
18
27
|
def show_text_with_positioning(*params)
|
19
28
|
# ignore kerning information
|
20
|
-
|
29
|
+
show_text params[0].reject { |e|
|
30
|
+
Numeric === e
|
31
|
+
}.join
|
21
32
|
end
|
22
33
|
|
23
34
|
end
|
data/lib/pdf/inspector/text.rb
CHANGED
@@ -8,6 +8,7 @@ module PDF
|
|
8
8
|
def initialize
|
9
9
|
@font_settings = []
|
10
10
|
@fonts = {}
|
11
|
+
@font_objects = {}
|
11
12
|
@strings = []
|
12
13
|
@character_spacing = []
|
13
14
|
@word_spacing = []
|
@@ -15,34 +16,44 @@ module PDF
|
|
15
16
|
@text_rendering_mode = []
|
16
17
|
end
|
17
18
|
|
18
|
-
def
|
19
|
-
@
|
19
|
+
def page=(page)
|
20
|
+
@state = PDF::Reader::PageState.new(page)
|
21
|
+
page.fonts.each do |label, stream|
|
22
|
+
@fonts[label] = stream[:BaseFont]
|
23
|
+
@font_objects[label] = PDF::Reader::Font.new(page.objects, stream)
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
22
27
|
def set_text_font_and_size(*params)
|
28
|
+
@state.set_text_font_and_size(*params)
|
23
29
|
@font_settings << { :name => @fonts[params[0]], :size => params[1] }
|
24
30
|
end
|
25
31
|
|
26
32
|
def show_text(*params)
|
27
33
|
@kerned << false
|
28
|
-
@strings << params[0]
|
34
|
+
@strings << @state.current_font.to_utf8(params[0])
|
29
35
|
end
|
30
36
|
|
31
37
|
def show_text_with_positioning(*params)
|
32
38
|
@kerned << true
|
33
39
|
# ignore kerning information
|
34
|
-
|
40
|
+
show_text params[0].reject { |e|
|
41
|
+
Numeric === e
|
42
|
+
}.join
|
35
43
|
end
|
36
44
|
|
37
45
|
def set_text_rendering_mode(*params)
|
46
|
+
@state.set_text_rendering_mode(*params)
|
38
47
|
@text_rendering_mode << params[0]
|
39
48
|
end
|
40
49
|
|
41
50
|
def set_character_spacing(*params)
|
51
|
+
@state.set_character_spacing(*params)
|
42
52
|
@character_spacing << params[0]
|
43
53
|
end
|
44
54
|
|
45
55
|
def set_word_spacing(*params)
|
56
|
+
@state.set_word_spacing(*params)
|
46
57
|
@word_spacing << params[0]
|
47
58
|
end
|
48
59
|
|
@@ -8,18 +8,12 @@ module PDF
|
|
8
8
|
@xobject_streams = {}
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
@page_xobjects
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def begin_page(*params)
|
17
|
-
@page_xobjects << []
|
18
|
-
end
|
19
|
-
|
20
|
-
def store_streams(resource_name, stream)
|
21
|
-
@xobject_streams[resource_name] = stream
|
11
|
+
def page=(page)
|
12
|
+
@page_xobjects << page.xobjects
|
13
|
+
page.xobjects.each do |label, stream|
|
14
|
+
@xobject_streams[label] = stream
|
15
|
+
end
|
22
16
|
end
|
23
17
|
end
|
24
18
|
end
|
25
|
-
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,9 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdf-inspector
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 1.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Gregory Brown
|
14
8
|
- Brad Ediger
|
15
9
|
- Daniel Nelson
|
@@ -18,98 +12,82 @@ authors:
|
|
18
12
|
autorequire:
|
19
13
|
bindir: bin
|
20
14
|
cert_chain: []
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
- !ruby/object:Gem::Dependency
|
15
|
+
date: 2013-04-08 00:00:00.000000000 Z
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
25
18
|
name: pdf-reader
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
hash: 59
|
33
|
-
segments:
|
34
|
-
- 0
|
35
|
-
- 9
|
36
|
-
- 0
|
37
|
-
version: 0.9.0
|
19
|
+
requirement: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '1.0'
|
38
24
|
type: :runtime
|
39
|
-
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '1.0'
|
40
31
|
description: |
|
41
32
|
This library provides a number of PDF::Reader[0] based tools for use in testing
|
42
33
|
PDF output. Presently, the primary purpose of this tool is to support the
|
43
34
|
tests found in Prawn[1], a pure Ruby PDF generation library.
|
44
|
-
|
35
|
+
|
45
36
|
However, it may be useful to others, so we have made it available as a gem in
|
46
37
|
its own right.
|
47
|
-
|
48
|
-
[0] https://github.com/yob/pdf-reader
|
49
|
-
[1] https://github.com/sandal/prawn
|
50
38
|
|
51
|
-
|
39
|
+
[0] https://github.com/yob/pdf-reader
|
40
|
+
[1] https://github.com/prawnpdf/prawn
|
41
|
+
email:
|
52
42
|
- gregory.t.brown@gmail.com
|
53
43
|
- brad@bradediger.com
|
54
44
|
- dnelson77@gmail.com
|
55
45
|
- greenberg@entryway.net
|
56
46
|
- jimmy@deefa.com
|
57
47
|
executables: []
|
58
|
-
|
59
48
|
extensions: []
|
60
|
-
|
61
|
-
extra_rdoc_files:
|
49
|
+
extra_rdoc_files:
|
62
50
|
- CHANGELOG
|
63
51
|
- README
|
64
|
-
files:
|
52
|
+
files:
|
65
53
|
- lib/pdf/inspector.rb
|
54
|
+
- lib/pdf/inspector/extgstate.rb
|
55
|
+
- lib/pdf/inspector/xobject.rb
|
66
56
|
- lib/pdf/inspector/page.rb
|
67
57
|
- lib/pdf/inspector/text.rb
|
68
58
|
- lib/pdf/inspector/graphics.rb
|
69
|
-
- lib/pdf/inspector/extgstate.rb
|
70
|
-
- lib/pdf/inspector/xobject.rb
|
71
59
|
- CHANGELOG
|
72
60
|
- README
|
73
61
|
- COPYING
|
74
62
|
- LICENSE
|
75
63
|
- GPLv2
|
76
64
|
- GPLv3
|
77
|
-
homepage: https://github.com/
|
65
|
+
homepage: https://github.com/prawnpdf/pdf-inspector
|
78
66
|
licenses: []
|
79
|
-
|
67
|
+
metadata: {}
|
80
68
|
post_install_message:
|
81
|
-
rdoc_options:
|
69
|
+
rdoc_options:
|
82
70
|
- --title
|
83
71
|
- PDF::Inspector
|
84
72
|
- --main
|
85
73
|
- README
|
86
74
|
- -q
|
87
|
-
require_paths:
|
75
|
+
require_paths:
|
88
76
|
- lib
|
89
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
none: false
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
hash: 3
|
104
|
-
segments:
|
105
|
-
- 0
|
106
|
-
version: "0"
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
107
87
|
requirements: []
|
108
|
-
|
109
88
|
rubyforge_project:
|
110
|
-
rubygems_version:
|
89
|
+
rubygems_version: 2.0.0
|
111
90
|
signing_key:
|
112
|
-
specification_version:
|
91
|
+
specification_version: 4
|
113
92
|
summary: A tool for analyzing PDF output
|
114
93
|
test_files: []
|
115
|
-
|