pdf2html_docker_wrapper_rmenu 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1300bd5ed337e5ffa17ebdf6c4caa2c60712855bf6c81ac40c5079574c327d00
4
+ data.tar.gz: 8efe3eacc315a5635dd7f0435312f1da856a0a0924782273137179e684e52410
5
+ SHA512:
6
+ metadata.gz: 9dfa695c3566e6ada4c19128a7ec4c8e41a00e0a68576e53586b10bab32f813e60ea4b629298d6ad9733a9f8722b237d3de293d51b344888cbdb082e6c0f99f7
7
+ data.tar.gz: bcb5906759770ff7a6879af0e332d7db226f51f3959d52e0b4286b53ef06a65781d90392f0df13791319f49008bfaf8cdf92f7e05ec7205bff366751fc368e88
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at me@aokarkau.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in pdf2html_docker.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,41 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pdf2html_docker_wrapper_rmenu (0.1.1)
5
+ terrapin (~> 0.6.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ climate_control (0.2.0)
11
+ diff-lcs (1.3)
12
+ irb (1.0.0)
13
+ rake (10.5.0)
14
+ rspec (3.8.0)
15
+ rspec-core (~> 3.8.0)
16
+ rspec-expectations (~> 3.8.0)
17
+ rspec-mocks (~> 3.8.0)
18
+ rspec-core (3.8.0)
19
+ rspec-support (~> 3.8.0)
20
+ rspec-expectations (3.8.3)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.8.0)
23
+ rspec-mocks (3.8.0)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.8.0)
26
+ rspec-support (3.8.0)
27
+ terrapin (0.6.0)
28
+ climate_control (>= 0.0.3, < 1.0)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ bundler (~> 2.0)
35
+ irb (~> 1.0.0)
36
+ pdf2html_docker_wrapper_rmenu!
37
+ rake (~> 10.0)
38
+ rspec (~> 3.0)
39
+
40
+ BUNDLED WITH
41
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Alex Okarkau
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # pdf2html_docker_wrapper_rmenu
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'pdf2html_docker_wrapper_rmenu'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install pdf2html_docker_wrapper_rmenu
18
+
19
+ **Note:** Make sure that you have docker installed in your OS, if not it will throw a **CommandNotFound** exception.
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ Pdf2htmlDocker.convert "/path/to/document.pdf", { option: "value", option: "value2" }, "output_file.html"
25
+
26
+ > Pdf2htmlDocker.convert "/home/document.pdf", { dest_dir: "/home/" }
27
+ ```
28
+
29
+ **Note:** The name of the output file and the options are optional, it works without it. If you put a mistaken option it will ignore it.
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
36
+
37
+ ## Contributing
38
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
43
+
44
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pdf2html_docker"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,98 @@
1
+ module Pdf2htmlDocker
2
+ CONVERTER_ARGS = [':pdf', ':html'].freeze
3
+
4
+ CONVERTER_OPTIONS = {
5
+ first_page: '--first-page',
6
+ last_page: '--last-page',
7
+ zoom: '--zoom',
8
+ fit_height: '--fit-height',
9
+ use_cropbox: '--use-cropbox',
10
+ hdpi: '--hdpi',
11
+ vdpi: '--vdpi',
12
+ embed: '--embed',
13
+ embed_css: '--embed-css',
14
+ embed_font: '--embed-font',
15
+ embed_image: '--embed-image',
16
+ embed_javascript: '--embed-javascript',
17
+ embed_outline: '--embed-outline',
18
+ split_pages: '--split-pages',
19
+ dest_dir: '--dest-dir',
20
+ css_filename: '--css-filename',
21
+ page_filename: '--page-filename',
22
+ outline_filename: '--outline-filename',
23
+ process_nontext: '--process-nontext',
24
+ process_outline: '--process-outline',
25
+ process_annotation: '--process-annotation',
26
+ process_form: '--process-form',
27
+ printing: '--printing',
28
+ fallback: '--fallback',
29
+ tmp_file_size_limit: '--tmp-file-size-limit',
30
+ embed_external_font: '--embed-external-font',
31
+ font_format: '--font-format',
32
+ decomponse_ligature: '--decompose-ligature',
33
+ auto_hint: '--auto-hint',
34
+ external_hint_tool: '--external-hint-tool',
35
+ stretch_narrow_glyph: '--stretch-narrow-glyph',
36
+ squeeze_wide_glyph: '--squeeze-wide-glyph',
37
+ override_fstype: '--override-fstype',
38
+ process_type3: '--process-type3',
39
+ heps: '--heps',
40
+ veps: '--veps',
41
+ space_threshold: '--space-threshold',
42
+ font_size_multiplier: '--font-size-multiplier',
43
+ space_as_offset: '--space-as-offset',
44
+ tounicode: '--tounicode',
45
+ optimize_text: '--optimize-text',
46
+ correct_text_visibility: '--correct-text-visibility',
47
+ bg_format: '--bg-format',
48
+ svg_node_count_limit: '--svg-node-count-limit',
49
+ svg_embed_bitmap: '--svg-embed-bitmap',
50
+ owner_password: '--owner-password',
51
+ user_password: '--user-password',
52
+ no_drm: '--no-drm',
53
+ clear_tmp: '--clean-tmp',
54
+ tmp_dir: '--tmp-dir',
55
+ data_dir: '--data-dir',
56
+ debug: '--debug',
57
+ proof: '--proof',
58
+ version: '--version',
59
+ help: '--help'
60
+ }.freeze
61
+
62
+ class OptionBuilder
63
+ attr_reader :keys
64
+
65
+ def initialize(args, options = {})
66
+ @keys = (CONVERTER_OPTIONS.keys & options.keys) + CONVERTER_ARGS
67
+ @options = normalize_options(options)
68
+ @args = args
69
+ end
70
+
71
+ def to_s
72
+ return '' if @keys.empty?
73
+
74
+ (array_from_options(@options, CONVERTER_OPTIONS) +
75
+ CONVERTER_ARGS).join(' ')
76
+ end
77
+
78
+ def to_h
79
+ @options.merge(@args)
80
+ end
81
+
82
+ private
83
+
84
+ def normalize_options(options)
85
+ return {} if options.nil? || @keys.nil?
86
+
87
+ @keys.each_with_object({}) do |f, hash|
88
+ hash[f] = options[f].to_s unless options[f].nil?
89
+ end
90
+ end
91
+
92
+ def array_from_options(hash, opts = hash)
93
+ hash.flat_map do |key, _val|
94
+ [opts[key].to_s, key.to_sym.inspect.to_s]
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,42 @@
1
+ require 'terrapin'
2
+ require 'pdf2html_docker/option_builder'
3
+
4
+ module Pdf2htmlDocker
5
+ DOCKER_COMMAND = 'docker run -v'.freeze
6
+ DOCKER_IMAGE = 'iapain/pdf2htmlex'.freeze
7
+ BASE_COMMAND = 'pdf2htmlEX'.freeze
8
+ DOCKER_VOLUME = ':/pdf'.freeze
9
+
10
+ class Service
11
+ attr_reader :line, :command_options, :input_dir, :input_file
12
+ attr_writer :command
13
+
14
+ def initialize(input_file, output_file = '', options = {})
15
+ @input_dir, @input_file = process_input_file(input_file)
16
+ args = { pdf: @input_file, html: output_file }
17
+ @command_options = OptionBuilder.new(args, options)
18
+ @line = ::Terrapin::CommandLine.new(command, @command_options.to_s)
19
+ end
20
+
21
+ def run
22
+ @line.run(@command_options.to_h)
23
+ rescue Terrapin::CommandNotFoundError, Terrapin::ExitStatusError => e
24
+ e
25
+ end
26
+
27
+ def command
28
+ @command ||= "#{DOCKER_COMMAND} #{@input_dir}#{DOCKER_VOLUME} #{DOCKER_IMAGE} #{BASE_COMMAND}"
29
+ end
30
+
31
+ private
32
+
33
+ def process_input_file(input_file)
34
+ splitted_dir = input_file.split('/')
35
+ file = splitted_dir.last
36
+ dir = (splitted_dir - [file]).join('/')
37
+ return ['~/', file] if dir.empty?
38
+
39
+ [dir, file]
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ module Pdf2htmlDocker
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,11 @@
1
+ require 'pdf2html_docker/version'
2
+ require 'pdf2html_docker/service'
3
+
4
+ module Pdf2htmlDocker
5
+ class Error < StandardError; end
6
+ def self.convert(input_file, options = {}, output_file = '')
7
+ Service.new(input_file, output_file, options).run
8
+ rescue ArgumentError => e
9
+ e
10
+ end
11
+ end
@@ -0,0 +1,42 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'pdf2html_docker/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'pdf2html_docker_wrapper_rmenu'
7
+ spec.version = Pdf2htmlDocker::VERSION
8
+ spec.authors = ['Alex Okarkau']
9
+ spec.email = ['me@aokarkau.com']
10
+
11
+ spec.summary = 'PDF to HTML converter'
12
+ spec.description = 'It converts any kind of PDF documents to HTML, maintaining the style'
13
+ spec.homepage = 'https://github.com/okorkov'
14
+ spec.license = 'MIT'
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
+
21
+ spec.metadata['homepage_uri'] = spec.homepage
22
+ spec.metadata['source_code_uri'] = 'https://github.com/okorkov'
23
+ spec.metadata['changelog_uri'] = 'https://github.com/okorkov'
24
+ else
25
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
26
+ 'public gem pushes.'
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = 'exe'
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ['lib']
37
+ spec.add_dependency 'terrapin', '~> 0.6.0'
38
+ spec.add_development_dependency 'bundler', '~> 2.0'
39
+ spec.add_development_dependency 'irb', '~> 1.0.0'
40
+ spec.add_development_dependency 'rake', '~> 10.0'
41
+ spec.add_development_dependency 'rspec', '~> 3.0'
42
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pdf2html_docker_wrapper_rmenu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Alex Okarkau
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-03-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: terrapin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.6.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.6.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: irb
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: It converts any kind of PDF documents to HTML, maintaining the style
84
+ email:
85
+ - me@aokarkau.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - CODE_OF_CONDUCT.md
91
+ - Gemfile
92
+ - Gemfile.lock
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - bin/console
97
+ - bin/setup
98
+ - lib/pdf2html_docker.rb
99
+ - lib/pdf2html_docker/option_builder.rb
100
+ - lib/pdf2html_docker/service.rb
101
+ - lib/pdf2html_docker/version.rb
102
+ - pdf2html_docker.gemspec
103
+ homepage: https://github.com/okorkov
104
+ licenses:
105
+ - MIT
106
+ metadata:
107
+ allowed_push_host: https://rubygems.org
108
+ homepage_uri: https://github.com/okorkov
109
+ source_code_uri: https://github.com/okorkov
110
+ changelog_uri: https://github.com/okorkov
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubygems_version: 3.4.3
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: PDF to HTML converter
130
+ test_files: []