pdfdiff 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/pdfdiff +55 -0
  3. metadata +59 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0b5c266f3a2d788bd478a3b096b1e7406c441bfd
4
+ data.tar.gz: 681009ff76f5005527bc5677c388e6ced6479ab1
5
+ SHA512:
6
+ metadata.gz: a9de76c04b70b0f7d4398ed9c9081dff62faa322c8196a2a6f43fa6c0ce098b0d961837a4f4b2b99db178a56d9e37265ad3f7d999c7d53336a12132431e6e686
7
+ data.tar.gz: 72efe8b5b54d117996da872d97e9fde152ab656ad1e7d4243c37cdaf56f1448f6700a0f2a4bd0d9a0b313d678e0b268b4b883ff2c108154e252efc716987305b
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "mini_magick"
4
+ require "securerandom"
5
+ require "fileutils"
6
+
7
+ def workdir(*paths)
8
+ unless @workdir
9
+ @workdir = "/tmp/#{SecureRandom.uuid}"
10
+ @workdir = "/tmp/#{SecureRandom.uuid}" while File.exists?(@workdir)
11
+ end
12
+
13
+ File.join(@workdir, *paths)
14
+ end
15
+
16
+ if ARGV.length != 3
17
+ puts "Usage: "
18
+ puts " pdfdiff FILE1.pdf FILE2.pdf RESULT.pdf"
19
+ exit 0
20
+ end
21
+
22
+ FileUtils.mkdir(workdir)
23
+ FileUtils.mkdir(workdir("input1"))
24
+ FileUtils.mkdir(workdir("input2"))
25
+ FileUtils.mkdir(workdir("output"))
26
+
27
+ converter = MiniMagick::Tool::Convert.new
28
+ converter << ARGV[0]
29
+ converter << workdir("input1", "page.png")
30
+ converter.call
31
+
32
+ converter = MiniMagick::Tool::Convert.new
33
+ converter << ARGV[1]
34
+ converter << workdir("input2", "page.png")
35
+ converter.call
36
+
37
+ merger = MiniMagick::Tool::Convert.new
38
+
39
+ index = 0
40
+ while File.exists?(workdir("input1", "page-#{index}.png")) && File.exists?(workdir("input2", "page-#{index}.png"))
41
+ compare = MiniMagick::Tool::Compare.new
42
+ compare << workdir("input1", "page-#{index}.png")
43
+ compare << workdir("input2", "page-#{index}.png")
44
+ compare << workdir("output", "page-#{index}.png")
45
+ compare.call(false)
46
+
47
+ merger << workdir("output", "page-#{index}.png")
48
+
49
+ index += 1
50
+ end
51
+
52
+ merger << ARGV[2]
53
+ merger.call
54
+
55
+ FileUtils.rm_rf(workdir)
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pdfdiff
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Yihang Ho
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mini_magick
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.3.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.3.3
27
+ description: Compute the differences between two PDF files
28
+ email: me@yihangho.com
29
+ executables:
30
+ - pdfdiff
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - bin/pdfdiff
35
+ homepage: https://github.com/yihangho/pdfdiff
36
+ licenses:
37
+ - MIT
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.4.7
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: diff - for PDFs
59
+ test_files: []