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,110 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === PdfParadise::RemoveImages
6
+ #
7
+ # This class will remove all images from a given .pdf file, by making use
8
+ # of ghostscript.
9
+ #
10
+ # Usage example:
11
+ #
12
+ # PdfParadise::RemoveImages.new(ARGV)
13
+ #
14
+ # =========================================================================== #
15
+ # require 'pdf_paradise/utility_scripts/remove_images.rb'
16
+ # =========================================================================== #
17
+ require 'pdf_paradise/base/base.rb'
18
+
19
+ module PdfParadise
20
+
21
+ class RemoveImages < ::PdfParadise::Base # === PdfParadise::RemoveImages
22
+
23
+ # ========================================================================= #
24
+ # === NAMESPACE
25
+ # ========================================================================= #
26
+ NAMESPACE = inspect
27
+
28
+ # ========================================================================= #
29
+ # === initialize
30
+ # ========================================================================= #
31
+ def initialize(
32
+ i = nil,
33
+ run_already = true
34
+ )
35
+ reset
36
+ set_input(i)
37
+ run if run_already
38
+ end
39
+
40
+ # ========================================================================= #
41
+ # === reset (reset tag)
42
+ # ========================================================================= #
43
+ def reset
44
+ super()
45
+ end
46
+
47
+ # ========================================================================= #
48
+ # === set_input
49
+ # ========================================================================= #
50
+ def set_input(i = '')
51
+ i = i.first if i.is_a? Array
52
+ i = i.to_s.dup
53
+ @input = i
54
+ end
55
+
56
+ # ========================================================================= #
57
+ # === input?
58
+ # ========================================================================= #
59
+ def input?
60
+ @input
61
+ end; alias input_file? input? # === input_file?
62
+
63
+ # ========================================================================= #
64
+ # === opnn
65
+ # ========================================================================= #
66
+ def opnn
67
+ super(NAMESPACE)
68
+ end
69
+
70
+ # ========================================================================= #
71
+ # === run (run tag)
72
+ # ========================================================================= #
73
+ def run
74
+ input_file = input_file?
75
+ this_output_file = 'only_text_is_kept_'+input_file
76
+ if File.exist? input_file
77
+ opnn; e 'Now removing all images from the file `'+sfile(input_file)+'`.'
78
+ opnn; e 'Will store into the file `'+sfile(this_output_file)+'`.'
79
+ _ = 'gs -o '+this_output_file+' -sDEVICE=pdfwrite -dFILTERVECTOR -dFILTERIMAGE '+input_file
80
+ esystem _
81
+ if File.exist? this_output_file
82
+ opnn; e 'The file `'+sfile(this_output_file)+'` has been created!'
83
+ end
84
+ else
85
+ e 'Please supply an argument to this class that should be a local'
86
+ e '.pdf file.'
87
+ end
88
+ end
89
+
90
+ # ========================================================================= #
91
+ # === PdfParadise::RemoveImages[]
92
+ # ========================================================================= #
93
+ def self.[](i = '')
94
+ new(i)
95
+ end
96
+
97
+ end
98
+
99
+ # =========================================================================== #
100
+ # === PdfParadise.remove_image
101
+ # =========================================================================== #
102
+ def self.remove_image(from_this_pdf_file = ARGV)
103
+ RemoveImage.new(from_this_pdf_file)
104
+ end
105
+
106
+ end
107
+
108
+ if __FILE__ == $PROGRAM_NAME
109
+ PdfParadise::RemoveImages.new(ARGV)
110
+ end # removeimagesfromthispdffile
@@ -0,0 +1,340 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === PdfParadise::SplitPdf
6
+ #
7
+ # Use this class to split up a .pdf file into several new documents.
8
+ # =========================================================================== #
9
+ # require 'pdf_paradise/utility_scripts/split_pdf.rb'
10
+ # =========================================================================== #
11
+ require 'pdf_paradise/base/base.rb'
12
+
13
+ module PdfParadise
14
+
15
+ class SplitPdf < PdfParadise::Base # === PdfParadise::SplitPdf
16
+
17
+ require 'pdf_paradise/pdf_file_n_total_pages.rb'
18
+
19
+ # ========================================================================= #
20
+ # === NAMESPACE
21
+ # ========================================================================= #
22
+ NAMESPACE = inspect
23
+
24
+ # ========================================================================= #
25
+ # === SPLIT_UP_INTO_N_CHUNKS
26
+ #
27
+ # Split up the .pdf file at hand into n chunks. This constant used to
28
+ # be set to 10 rather than 2.
29
+ # ========================================================================= #
30
+ SPLIT_UP_INTO_N_CHUNKS = 1 # 10
31
+
32
+ # ========================================================================= #
33
+ # === initialize
34
+ # ========================================================================= #
35
+ def initialize(
36
+ optional_arguments = nil,
37
+ run_already = true
38
+ )
39
+ reset
40
+ set_commandline_arguments(
41
+ optional_arguments
42
+ )
43
+ if block_given?
44
+ yielded = yield
45
+ if yielded.is_a? Hash
46
+ if yielded.has_key? :split_into_n_pages
47
+ set_n_pages(
48
+ yielded.delete(:split_into_n_pages)
49
+ )
50
+ end
51
+ if yielded.has_key? :store_in_this_directory
52
+ set_store_here(
53
+ yielded.delete(:store_in_this_directory)
54
+ )
55
+ end
56
+ end
57
+ end
58
+ run if run_already
59
+ end
60
+
61
+ # ========================================================================= #
62
+ # === reset
63
+ # ========================================================================= #
64
+ def reset
65
+ super()
66
+ set_split_up_into_chunks_of_n_pages
67
+ set_store_in_this_directory
68
+ # ======================================================================= #
69
+ # === @namespace
70
+ # ======================================================================= #
71
+ @namespace = NAMESPACE
72
+ # ======================================================================= #
73
+ # === @path
74
+ # ======================================================================= #
75
+ @path = nil
76
+ # ======================================================================= #
77
+ # === @use_convert_or_hexapdf
78
+ # ======================================================================= #
79
+ @use_convert_or_hexapdf = :convert # :hexapdf
80
+ end
81
+
82
+ # ========================================================================= #
83
+ # === set_store_in_this_directory
84
+ #
85
+ # By default we will store into the current working directory.
86
+ # ========================================================================= #
87
+ def set_store_in_this_directory(
88
+ i = return_pwd
89
+ )
90
+ case i
91
+ when :default
92
+ i = return_pwd
93
+ end
94
+ i = i.dup if i.frozen?
95
+ # ======================================================================= #
96
+ # We require a String.
97
+ # ======================================================================= #
98
+ i << '/' unless i.end_with? '/'
99
+ @store_in_this_directory = i
100
+ ensure_that_the_directory_exists(i)
101
+ end; alias set_store_here set_store_in_this_directory # === set_store_here
102
+
103
+ # ========================================================================= #
104
+ # === ensure_that_the_directory_exists
105
+ # ========================================================================= #
106
+ def ensure_that_the_directory_exists(this_directory = nil)
107
+ if this_directory
108
+ unless File.directory? this_directory
109
+ require 'fileutils'
110
+ FileUtils.mkdir_p(this_directory)
111
+ end
112
+ end
113
+ end
114
+
115
+ # ========================================================================= #
116
+ # === menu (menu tag)
117
+ # ========================================================================= #
118
+ def menu(
119
+ i = @commandline_arguments
120
+ )
121
+ if i.is_a? Array
122
+ i.each {|entry| menu(entry) }
123
+ else
124
+ case i
125
+ # ===================================================================== #
126
+ # === splitpdf --n-pages=1
127
+ # ===================================================================== #
128
+ when /^-?-?n(_|-)?pages=(.+)$/i # $2
129
+ _ = $2.to_s.dup
130
+ opnn; e 'We will split the .pdf file into '+sfancy(_.to_s)+' pages each.'
131
+ set_split_n_pages(_)
132
+ end
133
+ end
134
+ end
135
+
136
+ # ========================================================================= #
137
+ # === set_split_up_into_chunks_of_n_pages
138
+ # ========================================================================= #
139
+ def set_split_up_into_chunks_of_n_pages(
140
+ i = SPLIT_UP_INTO_N_CHUNKS
141
+ )
142
+ if i.is_a? Array
143
+ i = i.first
144
+ end
145
+ case i
146
+ when :max
147
+ i = 1
148
+ set_split_n_pages(
149
+ PdfParadise.n_pdf_pages?(
150
+ return_n_pages - 1
151
+ )
152
+ )
153
+ when nil,
154
+ :default
155
+ i = SPLIT_UP_INTO_N_CHUNKS
156
+ end
157
+ i = i.to_i # We need to keep this variable as Integer value.
158
+ @split_up_into_chunks_of_n_pages = i
159
+ end; alias set_split_n_pages set_split_up_into_chunks_of_n_pages # === set_split_n_pages
160
+ alias set_n_pages set_split_up_into_chunks_of_n_pages # === set_n_pages
161
+
162
+ # ========================================================================= #
163
+ # === return_n_pages
164
+ #
165
+ # This will return the amount of pages in the given .pdf file.
166
+ # ========================================================================= #
167
+ def return_n_pages(i = input?)
168
+ ::PdfParadise.n_pages?(i).to_i # We need an integer here.
169
+ end
170
+
171
+ # ========================================================================= #
172
+ # === n_chunks?
173
+ # ========================================================================= #
174
+ def n_chunks?
175
+ @split_up_into_chunks_of_n_pages
176
+ end
177
+
178
+ # ========================================================================= #
179
+ # === report_the_output_file_will_be_at
180
+ # ========================================================================= #
181
+ def report_the_output_file_will_be_at(output_file)
182
+ opnn; e 'The output file will be at:'
183
+ e
184
+ e " #{sfile(output_file)}"
185
+ e
186
+ end
187
+
188
+ # ========================================================================= #
189
+ # === return_name_of_the_output_file_based_on_this_filename
190
+ # ========================================================================= #
191
+ def return_name_of_the_output_file_based_on_this_filename(filename, index)
192
+ return @store_in_this_directory+
193
+ File.basename(filename).delete_suffix('.pdf')+
194
+ '_page'+(old_index.to_i+1).to_s+
195
+ '.pdf'
196
+ end
197
+
198
+ # ========================================================================= #
199
+ # === do_convert_this_file_via_hexapdf
200
+ # ========================================================================= #
201
+ def do_convert_this_file_via_hexapdf(i)
202
+ e 'This is currently unfinished.'
203
+ end
204
+
205
+ # ========================================================================= #
206
+ # === try_to_split_up_the_pdf
207
+ # ========================================================================= #
208
+ def try_to_split_up_the_pdf(
209
+ i = input_without_leading_hyphens?
210
+ )
211
+ i = i.first if i.is_a? Array
212
+ filename = i
213
+ if File.exist? i
214
+ n_pages = return_n_pages(i)
215
+ opnn; e "The file at `#{sfile(i)}` exists. We will next split"
216
+ opnn; e 'it up into chunks of '+simp(n_chunks?.to_s)+' pages.'
217
+ # ===================================================================== #
218
+ # We currently depend on "bin/convert" from ImageMagick. We
219
+ # will also try to preserve as much quality as possible.
220
+ # Unfortunately convert really has a lousy quality, so as
221
+ # of May 2022 we add hexapdf as option too.
222
+ # ===================================================================== #
223
+ # cmd_to_use = 'convert '.dup
224
+ case @use_convert_or_hexapdf
225
+ # ===================================================================== #
226
+ # === :convert
227
+ # ===================================================================== #
228
+ when :convert
229
+ cmd_to_use = 'convert -quality 98 '.dup
230
+ # ===================================================================== #
231
+ # === :hexapdf
232
+ # ===================================================================== #
233
+ when :hexapdf
234
+ do_convert_this_file_via_hexapdf(i)
235
+ exit
236
+ end
237
+
238
+ old_index = 0
239
+ n_chunks?.step(n_pages+1, n_chunks?) {|entry|
240
+ range = old_index.to_s+'-'+(entry - 1).to_s
241
+ _ = filename+'['+range+']'
242
+ # =================================================================== #
243
+ # Keep track of the name of the output file at hand.
244
+ # =================================================================== #
245
+ output_file = return_name_of_the_output_file_based_on_this_filename(filename, old_index+1)
246
+ report_the_output_file_will_be_at(output_file)
247
+ esystem(
248
+ "#{cmd_to_use}#{_} #{output_file}"
249
+ )
250
+ old_index = entry
251
+ }
252
+ # ===================================================================== #
253
+ # We may have to correct the command a bit to account for the
254
+ # very last .pdf pages.
255
+ # ===================================================================== #
256
+ n_possible_remaining_pages = n_pages % n_chunks?
257
+ if n_possible_remaining_pages > 0
258
+ # =================================================================== #
259
+ # Ok, now we know that we must do a modification because we know
260
+ # that there are n remaining pages left.
261
+ # =================================================================== #
262
+ range = old_index.to_s+'-'+((old_index+n_possible_remaining_pages)- 1).to_s
263
+ _ = filename+'['+range+']'+' '
264
+ output_file = @store_in_this_directory+'OUTPUT_PDF_FILE_'+range.tr('-','_')+'_'+File.basename(filename)
265
+ @path = output_file
266
+ opnn; e 'The output file will be at `'+sfile(output_file)+'`.'
267
+ esystem(
268
+ cmd_to_use+_+' '+output_file
269
+ )
270
+ end
271
+ else
272
+ opnn; no_file_at(i)
273
+ end
274
+ end
275
+
276
+ # ========================================================================= #
277
+ # === path?
278
+ # ========================================================================= #
279
+ def path?
280
+ @path
281
+ end
282
+
283
+ # ========================================================================= #
284
+ # === run
285
+ # ========================================================================= #
286
+ def run
287
+ menu
288
+ try_to_split_up_the_pdf
289
+ end
290
+
291
+ end
292
+
293
+ # =========================================================================== #
294
+ # === PdfParadise.split_this_pdf_file
295
+ #
296
+ # The first argument to this method should be the path to a locally
297
+ # existing .pdf file.
298
+ # =========================================================================== #
299
+ def self.split_this_pdf_file(
300
+ i = ARGV,
301
+ split_into_n_pages = 1,
302
+ store_in_this_directory = :default
303
+ )
304
+ _ = PdfParadise::SplitPdf.new(i) {{
305
+ split_into_n_pages: split_into_n_pages,
306
+ store_in_this_directory: store_in_this_directory
307
+ }}
308
+ _ # Return the object here.
309
+ end
310
+
311
+ # =========================================================================== #
312
+ # === PdfParadise.burst
313
+ #
314
+ # This will "burst" all pdf files out of a single .pdf file.
315
+ # =========================================================================== #
316
+ def self.burst(
317
+ i = ARGV,
318
+ split_into_n_pages = :max,
319
+ store_in_this_directory = :default
320
+ )
321
+ _ = PdfParadise::SplitPdf.new(i) {{
322
+ split_into_n_pages: split_into_n_pages,
323
+ store_in_this_directory: store_in_this_directory
324
+ }}
325
+ _ # Return the object here.
326
+ end
327
+
328
+ # =========================================================================== #
329
+ # === PdfParadise.convert
330
+ # =========================================================================== #
331
+ def self.convert(pdf_files)
332
+ handle = PdfParadise.split_this_pdf_file(pdf_files)
333
+ handle.path? # Return the file path as well.
334
+ end
335
+
336
+ end
337
+
338
+ if __FILE__ == $PROGRAM_NAME
339
+ PdfParadise::SplitPdf.new(ARGV)
340
+ end # split_pdf XIV-XVII_combined.pdf
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === PdfParadise::ToQdf
6
+ #
7
+ # This class will convert a .pdf file into a .qdf file.
8
+ #
9
+ # Usage example:
10
+ #
11
+ # PdfParadise::ToQdf.new(ARGV)
12
+ #
13
+ # =========================================================================== #
14
+ # require 'pdf_paradise/utility_scripts/to_qdf.rb'
15
+ # PdfParadise::ToQdf.new(ARGV)
16
+ # =========================================================================== #
17
+ require 'pdf_paradise/base/base.rb'
18
+
19
+ module PdfParadise
20
+
21
+ class ToQdf < ::PdfParadise::Base # === PdfParadise::ToQdf
22
+
23
+ # ========================================================================= #
24
+ # === NAMESPACE
25
+ # ========================================================================= #
26
+ NAMESPACE = inspect
27
+
28
+ # ========================================================================= #
29
+ # === initialize
30
+ # ========================================================================= #
31
+ def initialize(
32
+ commandline_arguments = nil,
33
+ run_already = true
34
+ )
35
+ reset
36
+ set_commandline_arguments(
37
+ commandline_arguments
38
+ )
39
+ run if run_already
40
+ end
41
+
42
+ # ========================================================================= #
43
+ # === reset (reset tag)
44
+ # ========================================================================= #
45
+ def reset
46
+ super()
47
+ # ======================================================================= #
48
+ # === @namespace
49
+ # ======================================================================= #
50
+ @namespace = NAMESPACE
51
+ end
52
+
53
+ # ========================================================================= #
54
+ # === set_commandline_arguments
55
+ # ========================================================================= #
56
+ def set_commandline_arguments(i = '')
57
+ i = [i].flatten.compact
58
+ @commandline_arguments = i
59
+ end
60
+
61
+ # ========================================================================= #
62
+ # === run (run tag)
63
+ # ========================================================================= #
64
+ def run
65
+ @commandline_arguments.each {|entry|
66
+ qdf_file = entry.sub(/\.?pdf$/,)
67
+ esystem "qpdf -qdf #{entry} #{qdf_file}.qdf"
68
+ }
69
+ end
70
+
71
+ # ========================================================================= #
72
+ # === PdfParadise::ToQdf[]
73
+ # ========================================================================= #
74
+ def self.[](i = '')
75
+ new(i)
76
+ end
77
+
78
+ end; end
79
+
80
+ if __FILE__ == $PROGRAM_NAME
81
+ PdfParadise::ToQdf.new(ARGV)
82
+ end # to_qdf
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'pdf_paradise/version/version.rb'
6
+ # =========================================================================== #
7
+ module PdfParadise
8
+
9
+ # ========================================================================= #
10
+ # === VERSION
11
+ # ========================================================================= #
12
+ VERSION = '0.1.66'
13
+
14
+ # ========================================================================= #
15
+ # === LAST_UPDATE
16
+ # ========================================================================= #
17
+ LAST_UPDATE = '15.09.2022'
18
+
19
+ end
@@ -0,0 +1,2 @@
1
+ In this directory we will put code that can be used on
2
+ the www.