pludoni_pdfutils 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +43 -45
- data/lib/pludoni/pdfutils/active_storage_wrapper.rb +1 -1
- data/lib/pludoni/pdfutils/compressor.rb +3 -2
- data/lib/pludoni/pdfutils/convert_document_to_pdf.rb +3 -2
- data/lib/pludoni/pdfutils/convert_image_to_pdf.rb +3 -2
- data/lib/pludoni/pdfutils/file_wrapper.rb +6 -4
- data/lib/pludoni/pdfutils/joiner.rb +5 -4
- data/lib/pludoni/pdfutils/local_file_wrapper.rb +5 -2
- data/lib/pludoni/pdfutils.rb +0 -2
- data/pludoni_pdfutils.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d8493c8060dffe855122702e48a5cb28d43292f0dc192f768d6b033c9f6a2e7
|
4
|
+
data.tar.gz: 18d0541e7a26189a90d97cc7ce5b16fd93a5e46f5e05b0885afc752919fa485e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95d9e311f1cba3fa1dd0a96e294432f0c4c1d8777dfc5b137d8839ce09b709d0c4811b01f434ea2ad660484938cc0aef8d89a093af699012743af631da8a43b7
|
7
|
+
data.tar.gz: 5c78e1a7799432e25c2b2502fbfd1add93d3b17ebebbfc18632b721fbf2efd030161498ff5773ed6ef20a56ed531006d76b742502d0d1a561480ff2fc6ee5a6f
|
data/Gemfile.lock
CHANGED
@@ -1,88 +1,86 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
|
4
|
+
pludoni_pdfutils (0.4.0)
|
5
5
|
activestorage (>= 5.2.0)
|
6
|
-
|
6
|
+
marcel
|
7
7
|
zeitwerk
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
actionpack (
|
13
|
-
actionview (=
|
14
|
-
activesupport (=
|
15
|
-
rack (~> 2.0, >= 2.
|
12
|
+
actionpack (7.0.7.2)
|
13
|
+
actionview (= 7.0.7.2)
|
14
|
+
activesupport (= 7.0.7.2)
|
15
|
+
rack (~> 2.0, >= 2.2.4)
|
16
16
|
rack-test (>= 0.6.3)
|
17
17
|
rails-dom-testing (~> 2.0)
|
18
18
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
19
|
-
actionview (
|
20
|
-
activesupport (=
|
19
|
+
actionview (7.0.7.2)
|
20
|
+
activesupport (= 7.0.7.2)
|
21
21
|
builder (~> 3.1)
|
22
22
|
erubi (~> 1.4)
|
23
23
|
rails-dom-testing (~> 2.0)
|
24
24
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
25
|
-
activejob (
|
26
|
-
activesupport (=
|
25
|
+
activejob (7.0.7.2)
|
26
|
+
activesupport (= 7.0.7.2)
|
27
27
|
globalid (>= 0.3.6)
|
28
|
-
activemodel (
|
29
|
-
activesupport (=
|
30
|
-
activerecord (
|
31
|
-
activemodel (=
|
32
|
-
activesupport (=
|
33
|
-
activestorage (
|
34
|
-
actionpack (=
|
35
|
-
activejob (=
|
36
|
-
activerecord (=
|
37
|
-
activesupport (=
|
28
|
+
activemodel (7.0.7.2)
|
29
|
+
activesupport (= 7.0.7.2)
|
30
|
+
activerecord (7.0.7.2)
|
31
|
+
activemodel (= 7.0.7.2)
|
32
|
+
activesupport (= 7.0.7.2)
|
33
|
+
activestorage (7.0.7.2)
|
34
|
+
actionpack (= 7.0.7.2)
|
35
|
+
activejob (= 7.0.7.2)
|
36
|
+
activerecord (= 7.0.7.2)
|
37
|
+
activesupport (= 7.0.7.2)
|
38
38
|
marcel (~> 1.0)
|
39
39
|
mini_mime (>= 1.1.0)
|
40
|
-
activesupport (
|
40
|
+
activesupport (7.0.7.2)
|
41
41
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
42
42
|
i18n (>= 1.6, < 2)
|
43
43
|
minitest (>= 5.1)
|
44
44
|
tzinfo (~> 2.0)
|
45
|
-
zeitwerk (~> 2.3)
|
46
45
|
builder (3.2.4)
|
47
|
-
concurrent-ruby (1.
|
46
|
+
concurrent-ruby (1.2.2)
|
48
47
|
crass (1.0.6)
|
49
|
-
erubi (1.
|
50
|
-
globalid (1.
|
48
|
+
erubi (1.12.0)
|
49
|
+
globalid (1.1.0)
|
51
50
|
activesupport (>= 5.0)
|
52
|
-
i18n (1.
|
51
|
+
i18n (1.14.1)
|
53
52
|
concurrent-ruby (~> 1.0)
|
54
|
-
loofah (2.
|
53
|
+
loofah (2.21.3)
|
55
54
|
crass (~> 1.0.2)
|
56
|
-
nokogiri (>= 1.
|
55
|
+
nokogiri (>= 1.12.0)
|
57
56
|
marcel (1.0.2)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
mini_mime (1.1.2)
|
62
|
-
minitest (5.16.3)
|
63
|
-
nokogiri (1.13.8-x86_64-linux)
|
57
|
+
mini_mime (1.1.5)
|
58
|
+
minitest (5.19.0)
|
59
|
+
nokogiri (1.15.4-x86_64-linux)
|
64
60
|
racc (~> 1.4)
|
65
|
-
racc (1.
|
66
|
-
rack (2.2.
|
67
|
-
rack-test (2.0
|
61
|
+
racc (1.7.1)
|
62
|
+
rack (2.2.8)
|
63
|
+
rack-test (2.1.0)
|
68
64
|
rack (>= 1.3)
|
69
|
-
rails-dom-testing (2.0
|
70
|
-
activesupport (>=
|
65
|
+
rails-dom-testing (2.2.0)
|
66
|
+
activesupport (>= 5.0.0)
|
67
|
+
minitest
|
71
68
|
nokogiri (>= 1.6)
|
72
|
-
rails-html-sanitizer (1.
|
73
|
-
loofah (~> 2.
|
69
|
+
rails-html-sanitizer (1.6.0)
|
70
|
+
loofah (~> 2.21)
|
71
|
+
nokogiri (~> 1.14)
|
74
72
|
rake (13.0.6)
|
75
|
-
tzinfo (2.0.
|
73
|
+
tzinfo (2.0.6)
|
76
74
|
concurrent-ruby (~> 1.0)
|
77
|
-
zeitwerk (2.6.
|
75
|
+
zeitwerk (2.6.11)
|
78
76
|
|
79
77
|
PLATFORMS
|
80
78
|
x86_64-linux
|
81
79
|
|
82
80
|
DEPENDENCIES
|
83
81
|
bundler
|
84
|
-
|
82
|
+
pludoni_pdfutils!
|
85
83
|
rake
|
86
84
|
|
87
85
|
BUNDLED WITH
|
88
|
-
2.
|
86
|
+
2.4.2
|
@@ -6,7 +6,7 @@ module Pludoni
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def to_tf
|
9
|
-
file = Tempfile.new([
|
9
|
+
file = Tempfile.new([@file.filename.base, @file.filename.extension_with_delimiter])
|
10
10
|
ActiveStorage::Downloader.new(@file.service).send(:download, @file.key, file)
|
11
11
|
file
|
12
12
|
end
|
@@ -7,7 +7,8 @@ module Pludoni::Pdfutils
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def run
|
10
|
-
|
10
|
+
fname = File.basename(@blob.filename.to_s, '.*')
|
11
|
+
tf = Tempfile.new([fname, '.pdf'])
|
11
12
|
tf.binmode
|
12
13
|
input = @blob.to_tf
|
13
14
|
cli = "gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=#{Shellwords.escape tf.path} #{Shellwords.escape input.path}"
|
@@ -17,7 +18,7 @@ module Pludoni::Pdfutils
|
|
17
18
|
raise CompressionFailed, "PDF Compression failed: \nStdout: #{stdout}\nStderr: #{stderr}"
|
18
19
|
end
|
19
20
|
|
20
|
-
FileWrapper.make(tf)
|
21
|
+
FileWrapper.make(tf, filename: fname + ".pdf")
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
@@ -7,9 +7,10 @@ module Pludoni::Pdfutils
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def run(&block)
|
10
|
+
fname = File.basename(@blob.filename.to_s, File.extname(@blob.filename.to_s))
|
10
11
|
@blob.open do |source|
|
11
12
|
# convert image to pdf
|
12
|
-
tf = Tempfile.new([
|
13
|
+
tf = Tempfile.new([fname, '.pdf'])
|
13
14
|
tf.binmode
|
14
15
|
|
15
16
|
command = ['soffice']
|
@@ -32,7 +33,7 @@ module Pludoni::Pdfutils
|
|
32
33
|
|
33
34
|
tf.open
|
34
35
|
|
35
|
-
FileWrapper.make(tf)
|
36
|
+
FileWrapper.make(tf, filename: "#{fname}.pdf")
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
@@ -7,9 +7,10 @@ module Pludoni::Pdfutils
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def run(&block)
|
10
|
+
fname = File.basename(@blob.filename.to_s, '.*')
|
10
11
|
@blob.open do |source|
|
11
12
|
# convert image to pdf
|
12
|
-
tf = Tempfile.new([
|
13
|
+
tf = Tempfile.new([fname, '.pdf'])
|
13
14
|
tf.binmode
|
14
15
|
cli = "gs -dNOSAFER -dPDFSETTINGS=/prepress -sDEVICE=pdfwrite -o #{tf.path} viewjpeg.ps -c \\(#{source.path}\\) viewJPEG"
|
15
16
|
|
@@ -18,7 +19,7 @@ module Pludoni::Pdfutils
|
|
18
19
|
raise ConversionFailedError, "PDF convertion failed: Command: #{cli}\nStdout: #{stdout}\nStderr: #{stderr}"
|
19
20
|
end
|
20
21
|
|
21
|
-
FileWrapper.make(tf)
|
22
|
+
FileWrapper.make(tf, filename: "#{fname}.pdf")
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
@@ -5,12 +5,16 @@ module Pludoni
|
|
5
5
|
@file = file
|
6
6
|
end
|
7
7
|
|
8
|
-
def self.make(blob_or_file)
|
8
|
+
def self.make(blob_or_file, filename: nil)
|
9
9
|
case blob_or_file
|
10
10
|
when ActiveStorage::Blob
|
11
11
|
ActiveStorageWrapper.new(blob_or_file)
|
12
12
|
when File, Tempfile
|
13
|
-
LocalFileWrapper.new(blob_or_file)
|
13
|
+
fw = LocalFileWrapper.new(blob_or_file)
|
14
|
+
if filename
|
15
|
+
fw.filename = filename
|
16
|
+
end
|
17
|
+
fw
|
14
18
|
when FileWrapper
|
15
19
|
blob_or_file
|
16
20
|
else
|
@@ -32,5 +36,3 @@ module Pludoni
|
|
32
36
|
end
|
33
37
|
end
|
34
38
|
end
|
35
|
-
|
36
|
-
|
@@ -7,17 +7,18 @@ module Pludoni::Pdfutils
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def run
|
10
|
-
|
10
|
+
fname = @blobs.map(&:filename).map { |i| i.split('.').first[0..20] }.join('-')
|
11
|
+
|
12
|
+
tf = Tempfile.new([fname, '.pdf'])
|
11
13
|
tf.binmode
|
12
14
|
tfs = @blobs.map { |i| i.to_tf }
|
13
15
|
cli = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=#{tf.path} #{tfs.map(&:path).join(' ')}"
|
14
|
-
|
15
|
-
stdout, stderr, status = Open3.capture3(cli)
|
16
|
+
stdout, stderr, status = Open3.capture3(cli)
|
16
17
|
unless status.success?
|
17
18
|
raise JoiningFailedError, "PDF Joining failed: \nStdout: #{stdout}\nStderr: #{stderr}"
|
18
19
|
end
|
19
20
|
|
20
|
-
FileWrapper.make(tf)
|
21
|
+
FileWrapper.make(tf, filename: "#{fname}.pdf")
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
@@ -1,12 +1,15 @@
|
|
1
|
+
require 'marcel'
|
1
2
|
module Pludoni
|
2
3
|
module Pdfutils
|
3
4
|
class LocalFileWrapper < FileWrapper
|
5
|
+
attr_writer :filename
|
6
|
+
|
4
7
|
def filesize
|
5
8
|
@file.size
|
6
9
|
end
|
7
10
|
|
8
11
|
def filename
|
9
|
-
@file.path.split("/").last
|
12
|
+
@filename || @file.path.split("/").last
|
10
13
|
end
|
11
14
|
|
12
15
|
def to_tf
|
@@ -19,7 +22,7 @@ module Pludoni
|
|
19
22
|
end
|
20
23
|
|
21
24
|
def content_type
|
22
|
-
|
25
|
+
Marcel::MimeType.for(@file)
|
23
26
|
ensure
|
24
27
|
@file.rewind
|
25
28
|
end
|
data/lib/pludoni/pdfutils.rb
CHANGED
data/pludoni_pdfutils.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
spec.name = "pludoni_pdfutils"
|
4
|
-
spec.version = "0.
|
4
|
+
spec.version = "0.4.0"
|
5
5
|
spec.authors = ["Stefan Wienert"]
|
6
6
|
spec.email = ["info@stefanwienert.de"]
|
7
7
|
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_dependency "activestorage", ">= 5.2.0"
|
21
21
|
spec.add_dependency "zeitwerk"
|
22
|
-
spec.add_dependency "
|
22
|
+
spec.add_dependency "marcel"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler"
|
25
25
|
spec.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pludoni_pdfutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Wienert
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activestorage
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: marcel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
|
-
rubygems_version: 3.
|
128
|
+
rubygems_version: 3.2.33
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: Convert to pdf, compress pdf, join pdf using Ghostscript
|