pdf_paradise 0.1.66

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pdf_paradise might be problematic. Click here for more details.

Files changed (110) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +705 -0
  3. data/bin/automatic_pdf_title +7 -0
  4. data/bin/combine_these_pdf_pages +7 -0
  5. data/bin/compress_via_hexapdf +7 -0
  6. data/bin/convert_markdown_to_pdf +7 -0
  7. data/bin/convert_pdf_to_text +7 -0
  8. data/bin/delete_first_page_of_this_pdf_file +7 -0
  9. data/bin/merge_then_open +7 -0
  10. data/bin/n_pages +10 -0
  11. data/bin/open_main_pdf +7 -0
  12. data/bin/pdf_paradise +9 -0
  13. data/bin/set_main_book +7 -0
  14. data/bin/set_title_of_this_pdf_file +15 -0
  15. data/doc/README.gen +662 -0
  16. data/doc/todo/todo.md +7 -0
  17. data/lib/pdf_paradise/base/base.rb +239 -0
  18. data/lib/pdf_paradise/base/colours.rb +36 -0
  19. data/lib/pdf_paradise/commandline/commandline.rb +101 -0
  20. data/lib/pdf_paradise/commandline/help.rb +73 -0
  21. data/lib/pdf_paradise/commandline/menu.rb +142 -0
  22. data/lib/pdf_paradise/compress/compress_via_hexapdf.rb +27 -0
  23. data/lib/pdf_paradise/compress_this_pdf_file.rb +87 -0
  24. data/lib/pdf_paradise/constants/constants.rb +76 -0
  25. data/lib/pdf_paradise/convert_text_to_pdf.rb +94 -0
  26. data/lib/pdf_paradise/css/project.css +17 -0
  27. data/lib/pdf_paradise/djvu_to_pdf.rb +85 -0
  28. data/lib/pdf_paradise/gui/README.md +6 -0
  29. data/lib/pdf_paradise/gui/fox/split_pdf_file.rb +77 -0
  30. data/lib/pdf_paradise/gui/gtk2/delete_the_first_or_the_last_page_of_this_pdf_file/delete_the_first_or_the_last_page_of_this_pdf_file.rb +39 -0
  31. data/lib/pdf_paradise/gui/gtk2/pdf_viewer/pdf_viewer.rb +34 -0
  32. data/lib/pdf_paradise/gui/gtk2/split_pdf_file/split_pdf_file.rb +34 -0
  33. data/lib/pdf_paradise/gui/gtk2/statistics_widget/statistics_widget.rb +34 -0
  34. data/lib/pdf_paradise/gui/gtk2/to_pdf/to_pdf.rb +32 -0
  35. data/lib/pdf_paradise/gui/gtk3/controller/controller.rb +212 -0
  36. data/lib/pdf_paradise/gui/gtk3/convert_pdf_to_text/convert_pdf_to_text.rb +34 -0
  37. data/lib/pdf_paradise/gui/gtk3/delete_the_first_or_the_last_page_of_this_pdf_file/delete_the_first_or_the_last_page_of_this_pdf_file.rb +39 -0
  38. data/lib/pdf_paradise/gui/gtk3/pdf_viewer/pdf_viewer.rb +34 -0
  39. data/lib/pdf_paradise/gui/gtk3/split_pdf_file/split_pdf_file.rb +34 -0
  40. data/lib/pdf_paradise/gui/gtk3/statistics_widget/statistics_widget.rb +34 -0
  41. data/lib/pdf_paradise/gui/gtk3/to_pdf/to_pdf.rb +32 -0
  42. data/lib/pdf_paradise/gui/libui/extract_all_images_from_this_pdf_file/extract_all_images_from_this_pdf_file.rb +223 -0
  43. data/lib/pdf_paradise/gui/libui/statistics_widget/statistics_widget.rb +233 -0
  44. data/lib/pdf_paradise/gui/shared_code/convert_pdf_to_text/convert_pdf_to_text_module.rb +277 -0
  45. data/lib/pdf_paradise/gui/shared_code/delete_the_first_or_the_last_page_of_this_pdf_file/delete_the_first_or_the_last_page_of_this_pdf_file_module.rb +443 -0
  46. data/lib/pdf_paradise/gui/shared_code/pdf_viewer/pdf_viewer.css +5 -0
  47. data/lib/pdf_paradise/gui/shared_code/pdf_viewer/pdf_viewer_module.rb +284 -0
  48. data/lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file.css +0 -0
  49. data/lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb +294 -0
  50. data/lib/pdf_paradise/gui/shared_code/statistics_widget/statistics_widget_module.rb +349 -0
  51. data/lib/pdf_paradise/gui/shared_code/to_pdf/to_pdf_module.rb +281 -0
  52. data/lib/pdf_paradise/hexapdf/001_rainbow_pattern_example.rb +0 -0
  53. data/lib/pdf_paradise/hexapdf/hexapdf.rb +123 -0
  54. data/lib/pdf_paradise/images/PDF_PARADISE_LOGO.png +0 -0
  55. data/lib/pdf_paradise/main_pdf/main_pdf.rb +444 -0
  56. data/lib/pdf_paradise/merge_pdf/menu.rb +63 -0
  57. data/lib/pdf_paradise/merge_pdf/merge_pdf.rb +306 -0
  58. data/lib/pdf_paradise/merge_pdf_namespace.rb +9 -0
  59. data/lib/pdf_paradise/merge_then_open/merge_then_open.rb +105 -0
  60. data/lib/pdf_paradise/pdf_file_n_total_pages.rb +249 -0
  61. data/lib/pdf_paradise/prawn_addons/README.md +2 -0
  62. data/lib/pdf_paradise/prawn_addons/prawn_addons.rb +17 -0
  63. data/lib/pdf_paradise/project/project.rb +22 -0
  64. data/lib/pdf_paradise/remove_pdf_password.rb +391 -0
  65. data/lib/pdf_paradise/requires/batch_require_toplevel_files.rb +22 -0
  66. data/lib/pdf_paradise/requires/colours.rb +7 -0
  67. data/lib/pdf_paradise/requires/colours_and_esystem_and_save_file_and_fileutils_and_opn.rb +11 -0
  68. data/lib/pdf_paradise/requires/esystem_and_colours.rb +10 -0
  69. data/lib/pdf_paradise/requires/esystem_and_opn_and_colours.rb +8 -0
  70. data/lib/pdf_paradise/requires/require_the_whole_project.rb +28 -0
  71. data/lib/pdf_paradise/requires/require_utility_scripts.rb +9 -0
  72. data/lib/pdf_paradise/set_main_book.rb +156 -0
  73. data/lib/pdf_paradise/set_pdf_title.rb +220 -0
  74. data/lib/pdf_paradise/sinatra/embeddable_interface.rb +318 -0
  75. data/lib/pdf_paradise/toplevel_methods/automatic_pdf_title.rb +55 -0
  76. data/lib/pdf_paradise/toplevel_methods/convert_epub_to_pdf.rb +27 -0
  77. data/lib/pdf_paradise/toplevel_methods/convert_markdown_to_pdf.rb +45 -0
  78. data/lib/pdf_paradise/toplevel_methods/convert_ppt_to_pdf.rb +35 -0
  79. data/lib/pdf_paradise/toplevel_methods/e.rb +16 -0
  80. data/lib/pdf_paradise/toplevel_methods/esystem.rb +19 -0
  81. data/lib/pdf_paradise/toplevel_methods/misc.rb +76 -0
  82. data/lib/pdf_paradise/toplevel_methods/number_pages.rb +38 -0
  83. data/lib/pdf_paradise/toplevel_methods/opened_pdf_files.rb +221 -0
  84. data/lib/pdf_paradise/toplevel_methods/query_pdf_title.rb +191 -0
  85. data/lib/pdf_paradise/toplevel_methods/reduce_size_of_this_pdf_file.rb +46 -0
  86. data/lib/pdf_paradise/toplevel_methods/roebe.rb +17 -0
  87. data/lib/pdf_paradise/toplevel_methods/rotate_pdf_file.rb +143 -0
  88. data/lib/pdf_paradise/toplevel_methods/to_pdf.rb +38 -0
  89. data/lib/pdf_paradise/utility_scripts/README.md +3 -0
  90. data/lib/pdf_paradise/utility_scripts/combine_these_pdf_pages.rb +118 -0
  91. data/lib/pdf_paradise/utility_scripts/convert_pdf_to_text.rb +175 -0
  92. data/lib/pdf_paradise/utility_scripts/delete_first_page_of_this_pdf_file.rb +221 -0
  93. data/lib/pdf_paradise/utility_scripts/delete_last_page_of_this_pdf_file.rb +180 -0
  94. data/lib/pdf_paradise/utility_scripts/delete_this_page_of_this_pdf_file.rb +329 -0
  95. data/lib/pdf_paradise/utility_scripts/extract_all_images_from_this_pdf_file.rb +129 -0
  96. data/lib/pdf_paradise/utility_scripts/extract_pdf_page.rb +283 -0
  97. data/lib/pdf_paradise/utility_scripts/pdf_optimizer.rb +111 -0
  98. data/lib/pdf_paradise/utility_scripts/pdf_statistics.rb +148 -0
  99. data/lib/pdf_paradise/utility_scripts/pdf_to_html.rb +75 -0
  100. data/lib/pdf_paradise/utility_scripts/remove_images.rb +110 -0
  101. data/lib/pdf_paradise/utility_scripts/split_pdf.rb +340 -0
  102. data/lib/pdf_paradise/utility_scripts/to_qdf.rb +82 -0
  103. data/lib/pdf_paradise/version/version.rb +19 -0
  104. data/lib/pdf_paradise/www/README.md +2 -0
  105. data/lib/pdf_paradise/www/sinatra/app.rb +276 -0
  106. data/lib/pdf_paradise/yaml/working_on_these_pdf_files.yml +4 -0
  107. data/lib/pdf_paradise.rb +5 -0
  108. data/pdf_paradise.gemspec +61 -0
  109. data/test/testing_pdf_paradise.rb +9 -0
  110. metadata +219 -0
@@ -0,0 +1,239 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'pdf_paradise/base/base.rb'; < ::PdfParadise::Base
6
+ # =========================================================================== #
7
+ require 'pdf_paradise/requires/colours_and_esystem_and_save_file_and_fileutils_and_opn.rb'
8
+
9
+ module PdfParadise
10
+
11
+ class Base # === PdfParadise::Base
12
+
13
+ require 'yaml'
14
+ require 'fileutils'
15
+ require 'pdf_paradise/base/colours.rb'
16
+ require 'pdf_paradise/toplevel_methods/roebe.rb'
17
+ require 'pdf_paradise/constants/constants.rb'
18
+
19
+ begin
20
+ require 'cliner'
21
+ rescue LoadError; end
22
+
23
+ # ========================================================================= #
24
+ # === NAMESPACE
25
+ # ========================================================================= #
26
+ NAMESPACE = inspect
27
+
28
+ # ========================================================================= #
29
+ # === initialize
30
+ # ========================================================================= #
31
+ def initialize
32
+ reset
33
+ end
34
+
35
+ # ========================================================================= #
36
+ # === reset
37
+ # ========================================================================= #
38
+ def reset
39
+ end
40
+
41
+ # ========================================================================= #
42
+ # === no_file_at
43
+ #
44
+ # This method (or its alias) can be used to notify the user that the
45
+ # given file does not exist at that given location (denoted by the
46
+ # argument called i).
47
+ # ========================================================================= #
48
+ def no_file_at(i)
49
+ e "No file called `#{sfile(i)}` exists at that target."
50
+ end; alias no_file_exists_at no_file_at # === no_file_exists_at
51
+
52
+ # ========================================================================= #
53
+ # === is_on_roebe?
54
+ # ========================================================================= #
55
+ def is_on_roebe?
56
+ ::PdfParadise.is_on_roebe?
57
+ end
58
+
59
+ # ========================================================================= #
60
+ # === set_commandline_arguments
61
+ # ========================================================================= #
62
+ def set_commandline_arguments(i)
63
+ i = [i].flatten.compact
64
+ @commandline_arguments = i
65
+ end
66
+
67
+ # ========================================================================= #
68
+ # === return_files_from_the_commandline_arguments
69
+ #
70
+ # This method will return all existing files from the commandline
71
+ # arguments.
72
+ # ========================================================================= #
73
+ def return_files_from_the_commandline_arguments
74
+ @commandline_arguments.select {|entry|
75
+ File.file?(entry.to_s)
76
+ }
77
+ end
78
+
79
+ # ========================================================================= #
80
+ # === mv (mv tag, move tag, rename tag)
81
+ # ========================================================================= #
82
+ def mv(old, new)
83
+ # ======================================================================= #
84
+ # We must check that both files exist, before we delete the new file,
85
+ # as we may otherwise end up without any .pdf file. This has happened
86
+ # to me in August 2019 when qpdf failed to do a conversion.
87
+ # ======================================================================= #
88
+ if File.file?(new) and File.file?(old)
89
+ File.delete(new)
90
+ end
91
+ if File.exist? old
92
+ FileUtils.mv(old, new)
93
+ else
94
+ e 'No file exists at '+sfile(old)+'.'
95
+ end
96
+ end; alias move_file mv # === move_file
97
+
98
+ # ========================================================================= #
99
+ # === return_pwd
100
+ # ========================================================================= #
101
+ def return_pwd
102
+ "#{Dir.pwd}/".squeeze('/')
103
+ end
104
+
105
+ # ========================================================================= #
106
+ # === commandline_arguments?
107
+ # ========================================================================= #
108
+ def commandline_arguments?
109
+ @commandline_arguments
110
+ end; alias input? commandline_arguments? # === input?
111
+
112
+ # ========================================================================= #
113
+ # === first_argument?
114
+ # ========================================================================= #
115
+ def first_argument?
116
+ @commandline_arguments.first
117
+ end
118
+
119
+ # ========================================================================= #
120
+ # === input_without_leading_hyphens?
121
+ #
122
+ # This method will return the input that will not begin with --.
123
+ # ========================================================================= #
124
+ def input_without_leading_hyphens?
125
+ @commandline_arguments.reject {|entry| entry.start_with? '--' }
126
+ end
127
+
128
+ # ========================================================================= #
129
+ # === return_commandline_arguments_starting_with_hyphens
130
+ # ========================================================================= #
131
+ def return_commandline_arguments_starting_with_hyphens(
132
+ i = @commandline_arguments
133
+ )
134
+ [i].flatten.select {|entry| entry.start_with? '--' }
135
+ end; alias return_hyphen_arguments return_commandline_arguments_starting_with_hyphens # === return_hyphen_arguments
136
+
137
+ # ========================================================================= #
138
+ # === mkdir
139
+ # ========================================================================= #
140
+ def mkdir(i)
141
+ FileUtils.mkdir_p(i)
142
+ end
143
+
144
+ # ========================================================================= #
145
+ # === copy_file
146
+ # ========================================================================= #
147
+ def copy_file(
148
+ from, to = (Dir.pwd+'/').squeeze('/')
149
+ )
150
+ if File.exist? from
151
+ FileUtils.cp(from, to)
152
+ end
153
+ end
154
+
155
+ # ========================================================================= #
156
+ # === change_directory (cd tag)
157
+ # ========================================================================= #
158
+ def change_directory(i)
159
+ Dir.chdir(i) if File.directory?(i)
160
+ end; alias cd change_directory # === cd
161
+
162
+ # ========================================================================= #
163
+ # === delete_file
164
+ #
165
+ # This method can be used to delete a local file.
166
+ # ========================================================================= #
167
+ def delete_file(i)
168
+ begin
169
+ File.delete(i)
170
+ rescue Errno::EACCES => error
171
+ e 'Could not delete the file at '+i+' - reason '\
172
+ 'being insufficient permission.'
173
+ e 'The error was:'
174
+ e
175
+ pp error
176
+ e
177
+ end
178
+ end
179
+
180
+ # ========================================================================= #
181
+ # === write_what_into
182
+ # ========================================================================= #
183
+ def write_what_into(
184
+ what, into
185
+ )
186
+ begin
187
+ require 'save_file/module' unless Object.const_defined?(:SaveFile)
188
+ rescue LoadError; end
189
+ if Object.const_defined?(:SaveFile)
190
+ SaveFile.write_what_into(what, into)
191
+ else
192
+ e 'Can not save into '+into+' as the save_file gem '\
193
+ 'is not available/installed.'
194
+ end
195
+ end; alias save_what_into write_what_into # === save_what_into
196
+
197
+ # ========================================================================= #
198
+ # === n_pages?
199
+ #
200
+ # This method will return how many pages are in the given .pdf file at
201
+ # hand.
202
+ # ========================================================================= #
203
+ def n_pages?(i)
204
+ unless PdfParadise.const_defined? :PdfFileNTotalPages
205
+ require 'pdf_paradise/pdf_file_n_total_pages.rb'
206
+ end
207
+ ::PdfParadise.n_pdf_pages?(i)
208
+ end
209
+
210
+ # ========================================================================= #
211
+ # === esystem
212
+ #
213
+ # This method can be used to execute system-commands.
214
+ # ========================================================================= #
215
+ def esystem(i)
216
+ e steelblue(i)
217
+ system(i)
218
+ end
219
+
220
+ # ========================================================================= #
221
+ # === opnn
222
+ # ========================================================================= #
223
+ def opnn(
224
+ i = @namespace
225
+ )
226
+ if i.is_a? String
227
+ i = { namespace: i }
228
+ end
229
+ Opn.opn(i)
230
+ end
231
+
232
+ # ========================================================================= #
233
+ # === log_dir?
234
+ # ========================================================================= #
235
+ def log_dir?
236
+ ::PdfParadise.log_dir?
237
+ end
238
+
239
+ end; end
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'pdf_paradise/base/colours.rb'
6
+ # =========================================================================== #
7
+ require 'pdf_paradise/requires/colours_and_esystem_and_save_file_and_fileutils_and_opn.rb'
8
+
9
+ module PdfParadise
10
+
11
+ class Base # === PdfParadise::Base
12
+
13
+ include Colours
14
+
15
+ # ========================================================================= #
16
+ # === orange
17
+ # ========================================================================= #
18
+ def orange(i)
19
+ ::Colours.orange(i)
20
+ end
21
+
22
+ # ========================================================================= #
23
+ # === steelblue
24
+ # ========================================================================= #
25
+ def steelblue(i)
26
+ ::Colours.steelblue(i)
27
+ end
28
+
29
+ # ========================================================================= #
30
+ # === rev
31
+ # ========================================================================= #
32
+ def rev
33
+ ::Colours.rev
34
+ end
35
+
36
+ end; end
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'pdf_paradise/commandline/commandline.rb'
6
+ # =========================================================================== #
7
+ module PdfParadise
8
+
9
+ # ========================================================================= #
10
+ # === @commandline_arguments
11
+ # ========================================================================= #
12
+ @commandline_arguments = []
13
+
14
+ # ========================================================================= #
15
+ # === PdfParadise.set_commandline_arguments
16
+ # ========================================================================= #
17
+ def self.set_commandline_arguments(i)
18
+ i = [i].flatten.compact
19
+ # ======================================================================= #
20
+ # We will also check if a file with that name exists. If so we
21
+ # will replace it via File.absolute_path().
22
+ # ======================================================================= #
23
+ i.map! {|entry|
24
+ if File.exist?(entry)
25
+ entry = File.absolute_path(entry)
26
+ end
27
+ entry
28
+ }
29
+ @commandline_arguments = i
30
+ end
31
+
32
+ # ========================================================================= #
33
+ # === PdfParadise.commandline_arguments?
34
+ # ========================================================================= #
35
+ def self.commandline_arguments?
36
+ @commandline_arguments
37
+ end
38
+
39
+ # ========================================================================= #
40
+ # === @use_this_pdf_file
41
+ # ========================================================================= #
42
+ @use_this_pdf_file = nil
43
+
44
+ # ========================================================================= #
45
+ # === PdfParadise.set_use_this_pdf_file
46
+ # ========================================================================= #
47
+ def self.set_use_this_pdf_file(i)
48
+ @use_this_pdf_file = i.to_s.dup
49
+ end
50
+
51
+ # ========================================================================= #
52
+ # === PdfParadise.autoconvert_pdf_files_in_the_main_directory
53
+ # ========================================================================= #
54
+ def self.autoconvert_pdf_files_in_the_main_directory(
55
+ target = "#{AUTOCONVERT_PDF_FILES_RESIDING_IN_THIS_DIRECTORY}*.pdf"
56
+ )
57
+ require 'pdf_paradise/utility_scripts/split_pdf.rb'
58
+ all_pdf_files = Dir[target]
59
+ if all_pdf_files.empty?
60
+ e "No files found at #{target}."
61
+ else
62
+ all_pdf_files.each {|this_pdf_file|
63
+ PdfParadise.split_this_pdf_file(
64
+ this_pdf_file,
65
+ 1,
66
+ AUTOCONVERT_PDF_FILES_RESIDING_IN_THIS_DIRECTORY
67
+ )
68
+ }
69
+ end
70
+ end; self.instance_eval { alias autoconvert_pdf_files autoconvert_pdf_files_in_the_main_directory } # === PdfParadise.autoconvert_pdf_files
71
+
72
+ # ========================================================================= #
73
+ # === PdfParadise.open_the_default_pdf_files
74
+ #
75
+ # To invoke this method, do:
76
+ #
77
+ # pdfpa --open-pdf-files
78
+ #
79
+ # ========================================================================= #
80
+ def self.open_the_default_pdf_files(
81
+ use_this_file = ::PdfParadise.file_working_on_these_pdf_files
82
+ )
83
+ if File.exist? use_this_file
84
+ dataset = YAML.load_file(use_this_file)
85
+ dataset.each {|file|
86
+ esystem "atril #{file} &"
87
+ }
88
+ end
89
+ end
90
+
91
+ # ========================================================================= #
92
+ # === PdfParadise.start_the_most_important_libui_wrapper
93
+ # ========================================================================= #
94
+ def self.start_the_most_important_libui_wrapper(
95
+ optional_commandline_arguments = nil
96
+ )
97
+ require 'pdf_paradise/gui/libui/extract_all_images_from_this_pdf_file/extract_all_images_from_this_pdf_file.rb'
98
+ PdfParadise::GUI::LibUI::ExtractAllImagesFromThisPdfFile.new(optional_commandline_arguments)
99
+ end
100
+
101
+ end
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'pdf_paradise/commandline/help.rb'
6
+ # =========================================================================== #
7
+ module PdfParadise
8
+
9
+ # ========================================================================= #
10
+ # === PdfParadise.gold
11
+ # ========================================================================= #
12
+ def self.gold(i = '')
13
+ if Object.const_defined? :Colours
14
+ i = Colours.gold(i)
15
+ end
16
+ i
17
+ end
18
+
19
+ # ========================================================================= #
20
+ # === PdfParadise.show_help
21
+ #
22
+ # Show the documented help options of the PdfParadise project.
23
+ #
24
+ # To invoke this method from the commandline, do:
25
+ #
26
+ # pdf_paradise --help
27
+ #
28
+ # ========================================================================= #
29
+ def self.show_help
30
+ e 'The available options are:'
31
+ e
32
+ e gold(' pdf_paradise --use-this-pdf-file=foobar.pdf --set_title="Hello world!"')
33
+ e
34
+ e " ^^^ this can be used to modify a .pdf's title"
35
+ e
36
+ e gold(' pdf_paradise --shrink-pdf-size-of=foobar.pdf')
37
+ e
38
+ e " ^^^ this can be used to shrinke a .pdf file"
39
+ e
40
+ e gold(' pdf_paradise --store-open-pdf-files')
41
+ e
42
+ e ' ^^^ store all currently open .pdf files into a local file.'
43
+ e
44
+ e gold(' pdf_paradise --open-last-pdf-files')
45
+ e
46
+ e ' ^^^ open the last opened .pdf files via a local PDF reader.'
47
+ e
48
+ e gold(' pdf_paradise --show_last_opened_pdf_files')
49
+ e
50
+ e ' ^^^ show which .pdf files were last open.'
51
+ e
52
+ e gold(' pdf_paradise --gui')
53
+ e gold(' pdf_paradise --gtk')
54
+ e
55
+ e ' ^^^ to start the ruby-gtk2 bindings for the pdf_paradise.'
56
+ e
57
+ e gold(' pdf_paradise --autoconvert')
58
+ e
59
+ e ' ^^^ to autoconvert all .pdf files in the main directory '\
60
+ 'into standalone .pdf files.'
61
+ e
62
+ e gold(' pdf_paradise --sinatra')
63
+ e
64
+ e ' ^^^ start the (minimal) sinatra-interface of the pdf_paradise '\
65
+ 'project'
66
+ e
67
+ e gold(' pdf_paradise --libui')
68
+ e
69
+ e ' ^^^ start the libui GUI'
70
+ e
71
+ end
72
+
73
+ end
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'pdf_paradise/commandline/menu.rb'
6
+ # =========================================================================== #
7
+ module PdfParadise
8
+
9
+ require 'pdf_paradise/set_pdf_title.rb'
10
+ require 'pdf_paradise/toplevel_methods/e.rb'
11
+ require 'pdf_paradise/toplevel_methods/reduce_size_of_this_pdf_file.rb'
12
+ require 'pdf_paradise/toplevel_methods/opened_pdf_files.rb'
13
+ require 'pdf_paradise/commandline/commandline.rb'
14
+ require 'pdf_paradise/commandline/help.rb'
15
+
16
+ # ========================================================================= #
17
+ # === PdfParadise.menu (menu tag)
18
+ # ========================================================================= #
19
+ def self.menu(i)
20
+ if i.is_a? Array
21
+ i.each {|entry| menu(entry) }
22
+ else
23
+ case i # case tag
24
+ # ===================================================================== #
25
+ # === pdfpa --libui
26
+ #
27
+ # This entry point will always refer to the most important
28
+ # libui widget.
29
+ # ===================================================================== #
30
+ when /^-?-?libui$/
31
+ start_the_most_important_libui_wrapper(commandline_arguments?)
32
+ # ===================================================================== #
33
+ # === pdfpa --open-pdf-files
34
+ # ===================================================================== #
35
+ when /^-?-?open(-|_)?pdf(-|_)?files$/
36
+ open_the_default_pdf_files
37
+ # ===================================================================== #
38
+ # === pdfparadise --controller
39
+ # ===================================================================== #
40
+ when /^-?-?controller$/
41
+ require 'pdf_paradise/gui/gtk3/controller/controller.rb'
42
+ PdfParadise::GUI::Gtk::Controller.run
43
+ # ===================================================================== #
44
+ # === --use-this-pdf-file=DONE_Life_History_Evolution_WS_17_4.pdf
45
+ # ===================================================================== #
46
+ when /^-?-?use(-|_)?this(-|_)?pdf(-|_)?file=(.+)$/, # === $4
47
+ /^-?-?set(-|_)?pdf(-|_)?title=(.+)$/, # === $3
48
+ /^-?-?use(-|_)?this(-|_)?title=(.+)$/ # === $4
49
+ i = $3 # <- This is for the second line ^^^.
50
+ i = $4 if $4 # <- And this is for the first line.
51
+ set_use_this_pdf_file(i)
52
+ # ===================================================================== #
53
+ # === pdf_paradise --sinatra
54
+ # ===================================================================== #
55
+ when /^-?-?sinatra$/i,
56
+ /^-?-?www$/i # === pdf_paradise --www
57
+ require 'pdf_paradise/www/sinatra/app.rb'
58
+ PdfParadise.start_sinatra_interface
59
+ # ===================================================================== #
60
+ # === pdf_paradise --autoconvert
61
+ # ===================================================================== #
62
+ when /^-?-?autoconvert$/i
63
+ autoconvert_pdf_files_in_the_main_directory
64
+ # ===================================================================== #
65
+ # === pdf_paradise --gui
66
+ # === pdf_paradise --gtk
67
+ # ===================================================================== #
68
+ when /^-?-?gui$/,
69
+ /^-?-?gtk$/
70
+ require 'pdf_paradise/gui/gtk2/split_pdf_file/split_pdf_file.rb'
71
+ PdfParadise.start_gtk_gui
72
+ # ===================================================================== #
73
+ # === pdf_paradise --show_last_opened_pdf_files
74
+ # ===================================================================== #
75
+ when /^-?-?show(-|_)?last(-|_)?opened(-|_)?pdf(-|_)?files$/i,
76
+ /^-?-?pdf(-|_)?file(-|_)?content$/i, # pdfparadise --pdf-file-content
77
+ /^-?-?last(-|_)?open(-|_)?pdf\??$/i,
78
+ /^-?-?last-pdf$/i,
79
+ /^-?-?last\??$/i,
80
+ /^-?-?pdf\??$/i # pdfparadise --pdf?
81
+ PdfParadise.show_last_opened_pdf_files
82
+ # ===================================================================== #
83
+ # === pdfparadise --store-open-pdf-files
84
+ # ===================================================================== #
85
+ when /^-?-?store(-|_| )?open(-|_| )?pdf(-|_| )?files$/,
86
+ /^-?-?store(-|_| )?open(-|_| )?pdfs?$/,
87
+ /^-?-?store(-|_| )?pdf(-|_| )?files$/,
88
+ /^-?-?store(-|_| )?pdfs$/
89
+ PdfParadise.store_all_currently_open_pdf_files
90
+ # ===================================================================== #
91
+ # === pdf_paradise --array-all-currently-opened-pdf-files
92
+ # ===================================================================== #
93
+ when /^-?-?array(-|_| )?all(-|_| )?currently(-|_| )?opened(-|_| )?pdf(-|_| )?files$/i,
94
+ /^-?-?show(-|_| )?currently(-|_| )?open(-|_| )?pdf(-|_| )?files$/i
95
+ PdfParadise.return_array_of_all_currently_opened_pdf_files(:do_not_run_locate).each {|entry|
96
+ e entry
97
+ }
98
+ # ===================================================================== #
99
+ # === pdfparadise --open-last-pdf-files
100
+ # ===================================================================== #
101
+ when /^-?-?open(-|_| )?last(-|_| )?pdf(-|_| )?files$/,
102
+ /^-?-?open(-|_| )?last(-|_| )?opened(-|_| )?pdf(-|_| )?files$/,
103
+ /^-?-?open(-|_| )?last(-|_| )?pdfs$/,
104
+ /^-?-?main$/, # <- This is the main task (main tag)
105
+ /^-?-?restore$/
106
+ PdfParadise.open_last_opened_pdf_files
107
+ # ===================================================================== #
108
+ # === pdf_paradise --shrink-pdf-size-of=foobar.pdf
109
+ # ===================================================================== #
110
+ when /^-?-?shrink(-|_)?pdf(-|_)?size(-|_)?of=(.+)/i,
111
+ /^-?-?shrink=(.+)/i
112
+ this_file = $1.to_s.dup
113
+ this_file = $4.to_s.dup if $4
114
+ reduce_size_of_this_pdf_file(this_file)
115
+ # ===================================================================== #
116
+ # === pdf_paradise --help
117
+ # ===================================================================== #
118
+ when /^-?-?help/
119
+ show_help
120
+ # ===================================================================== #
121
+ # === --set_title="Hello world!"
122
+ # ===================================================================== #
123
+ when /^--set(-|_)?title=(.+)$/,
124
+ /^--title=(.+)$/
125
+ # =================================================================== #
126
+ # @use_this_pdf_file has to have been set properly before calling
127
+ # this method.
128
+ # =================================================================== #
129
+ i = $1
130
+ i = $2 if $2
131
+ PdfParadise.set_title_of_this_pdf_file(@use_this_pdf_file, i)
132
+ else
133
+ e "Unknown command: #{i}" unless File.exist?(i)
134
+ end
135
+ end
136
+ end
137
+
138
+ end
139
+
140
+ if __FILE__ == $PROGRAM_NAME
141
+ PdfParadise.menu(ARGV)
142
+ end
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'pdf_paradise/compress/compress_via_hexapdf.rb'
6
+ # PdfParadise.compress_via_pdf(ARGV)
7
+ # =========================================================================== #
8
+ module PdfParadise
9
+
10
+ # ========================================================================= #
11
+ # === PdfParadise.compress_via_pdf
12
+ # ========================================================================= #
13
+ def self.compress_via_pdf(
14
+ this_file = 'foobar.pdf'
15
+ )
16
+ if this_file.is_a? Array
17
+ this_file = this_file.first
18
+ end
19
+ require 'pdf_paradise/hexapdf/hexapdf.rb'
20
+ HexaPDF.optimize_this_pdf_file(this_file)
21
+ end
22
+
23
+ end
24
+
25
+ if __FILE__ == $PROGRAM_NAME
26
+ PdfParadise.compress_via_pdf(ARGV)
27
+ end # rb $RUBY_SRC/pdf_paradise/lib/pdf_paradise/compress/compress_via_hexapdf.rb ack.pdf