pdf_paradise 0.1.43

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 (93) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +376 -0
  3. data/bin/automatic_pdf_title +7 -0
  4. data/bin/convert_markdown_to_pdf +7 -0
  5. data/bin/convert_pdf_to_text +7 -0
  6. data/bin/merge_then_open +7 -0
  7. data/bin/n_pages +10 -0
  8. data/bin/open_main_pdf +7 -0
  9. data/bin/pdf_paradise +7 -0
  10. data/bin/set_main_book +7 -0
  11. data/bin/set_title_of_this_pdf_file +15 -0
  12. data/doc/README.gen +348 -0
  13. data/doc/todo/todo.md +2 -0
  14. data/lib/pdf_paradise.rb +5 -0
  15. data/lib/pdf_paradise/base/base.rb +173 -0
  16. data/lib/pdf_paradise/commandline/help.rb +69 -0
  17. data/lib/pdf_paradise/commandline/menu.rb +160 -0
  18. data/lib/pdf_paradise/compress_this_pdf_file.rb +82 -0
  19. data/lib/pdf_paradise/constants/constants.rb +59 -0
  20. data/lib/pdf_paradise/convert_text_to_pdf.rb +94 -0
  21. data/lib/pdf_paradise/css/project.css +17 -0
  22. data/lib/pdf_paradise/djvu_to_pdf.rb +85 -0
  23. data/lib/pdf_paradise/gui/README.md +6 -0
  24. data/lib/pdf_paradise/gui/fox/split_pdf_file.rb +77 -0
  25. 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
  26. data/lib/pdf_paradise/gui/gtk2/pdf_viewer/pdf_viewer.rb +34 -0
  27. data/lib/pdf_paradise/gui/gtk2/split_pdf_file/split_pdf_file.rb +34 -0
  28. data/lib/pdf_paradise/gui/gtk2/statistics_widget/statistics_widget.rb +34 -0
  29. data/lib/pdf_paradise/gui/gtk2/to_pdf/to_pdf.rb +32 -0
  30. data/lib/pdf_paradise/gui/gtk3/controller/controller.rb +197 -0
  31. data/lib/pdf_paradise/gui/gtk3/convert_pdf_to_text/convert_pdf_to_text.rb +34 -0
  32. 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
  33. data/lib/pdf_paradise/gui/gtk3/pdf_viewer/pdf_viewer.rb +34 -0
  34. data/lib/pdf_paradise/gui/gtk3/split_pdf_file/split_pdf_file.rb +34 -0
  35. data/lib/pdf_paradise/gui/gtk3/statistics_widget/statistics_widget.rb +34 -0
  36. data/lib/pdf_paradise/gui/gtk3/to_pdf/to_pdf.rb +32 -0
  37. data/lib/pdf_paradise/gui/shared_code/convert_pdf_to_text/convert_pdf_to_text_module.rb +277 -0
  38. 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 +428 -0
  39. data/lib/pdf_paradise/gui/shared_code/pdf_viewer/pdf_viewer.css +5 -0
  40. data/lib/pdf_paradise/gui/shared_code/pdf_viewer/pdf_viewer_module.rb +284 -0
  41. data/lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file.css +0 -0
  42. data/lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb +294 -0
  43. data/lib/pdf_paradise/gui/shared_code/statistics_widget/statistics_widget_module.rb +333 -0
  44. data/lib/pdf_paradise/gui/shared_code/to_pdf/to_pdf_module.rb +273 -0
  45. data/lib/pdf_paradise/main_pdf/main_pdf.rb +437 -0
  46. data/lib/pdf_paradise/merge_pdf/menu.rb +63 -0
  47. data/lib/pdf_paradise/merge_pdf/merge_pdf.rb +292 -0
  48. data/lib/pdf_paradise/merge_pdf_namespace.rb +9 -0
  49. data/lib/pdf_paradise/merge_then_open/merge_then_open.rb +105 -0
  50. data/lib/pdf_paradise/pdf_file_n_total_pages.rb +227 -0
  51. data/lib/pdf_paradise/project/project_base_directory.rb +22 -0
  52. data/lib/pdf_paradise/remove_pdf_password.rb +392 -0
  53. data/lib/pdf_paradise/requires/batch_require_toplevel_files.rb +22 -0
  54. data/lib/pdf_paradise/requires/colours.rb +7 -0
  55. data/lib/pdf_paradise/requires/colours_and_esystem_and_save_file_and_fileutils_and_opn.rb +11 -0
  56. data/lib/pdf_paradise/requires/esystem_and_colours.rb +10 -0
  57. data/lib/pdf_paradise/requires/esystem_and_opn_and_colours.rb +8 -0
  58. data/lib/pdf_paradise/requires/require_the_whole_project.rb +25 -0
  59. data/lib/pdf_paradise/requires/require_utility_scripts.rb +7 -0
  60. data/lib/pdf_paradise/rotate_pdf_file.rb +144 -0
  61. data/lib/pdf_paradise/set_main_book.rb +156 -0
  62. data/lib/pdf_paradise/set_pdf_title.rb +218 -0
  63. data/lib/pdf_paradise/sinatra/embeddable_interface.rb +315 -0
  64. data/lib/pdf_paradise/toplevel_methods/automatic_pdf_title.rb +55 -0
  65. data/lib/pdf_paradise/toplevel_methods/convert_epub_to_pdf.rb +27 -0
  66. data/lib/pdf_paradise/toplevel_methods/convert_markdown_to_pdf.rb +43 -0
  67. data/lib/pdf_paradise/toplevel_methods/convert_ppt_to_pdf.rb +35 -0
  68. data/lib/pdf_paradise/toplevel_methods/e.rb +16 -0
  69. data/lib/pdf_paradise/toplevel_methods/esystem.rb +19 -0
  70. data/lib/pdf_paradise/toplevel_methods/misc.rb +52 -0
  71. data/lib/pdf_paradise/toplevel_methods/number_pages.rb +38 -0
  72. data/lib/pdf_paradise/toplevel_methods/opened_pdf_files.rb +191 -0
  73. data/lib/pdf_paradise/toplevel_methods/query_pdf_title.rb +182 -0
  74. data/lib/pdf_paradise/toplevel_methods/reduce_size_of_this_pdf_file.rb +43 -0
  75. data/lib/pdf_paradise/toplevel_methods/roebe.rb +17 -0
  76. data/lib/pdf_paradise/toplevel_methods/to_pdf.rb +38 -0
  77. data/lib/pdf_paradise/utility_scripts/README.md +3 -0
  78. data/lib/pdf_paradise/utility_scripts/convert_pdf_to_text.rb +166 -0
  79. data/lib/pdf_paradise/utility_scripts/delete_first_page_of_this_pdf_file.rb +185 -0
  80. data/lib/pdf_paradise/utility_scripts/delete_last_page_of_this_pdf_file.rb +180 -0
  81. data/lib/pdf_paradise/utility_scripts/delete_this_page_of_this_pdf_file.rb +310 -0
  82. data/lib/pdf_paradise/utility_scripts/extract_pdf_page.rb +280 -0
  83. data/lib/pdf_paradise/utility_scripts/pdf_optimizer.rb +113 -0
  84. data/lib/pdf_paradise/utility_scripts/pdf_statistics.rb +150 -0
  85. data/lib/pdf_paradise/utility_scripts/remove_images.rb +110 -0
  86. data/lib/pdf_paradise/utility_scripts/split_pdf.rb +294 -0
  87. data/lib/pdf_paradise/utility_scripts/to_qdf.rb +82 -0
  88. data/lib/pdf_paradise/version/version.rb +19 -0
  89. data/lib/pdf_paradise/www/README.md +2 -0
  90. data/lib/pdf_paradise/www/sinatra/app.rb +276 -0
  91. data/pdf_paradise.gemspec +64 -0
  92. data/test/testing_pdf_paradise.rb +9 -0
  93. metadata +216 -0
@@ -0,0 +1,315 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === PdfParadise::EmbeddableInterface
6
+ #
7
+ # The code in this file can be used to "embed" the functionality of
8
+ # PdfParadise in web-applications, in particular in sinatra.
9
+ #
10
+ # This depends on the cyberweb project.
11
+ # =========================================================================== #
12
+ # require 'pdf_paradise/sinatra/embeddable_interface.rb'
13
+ # include PdfParadise::EmbeddableInterface
14
+ # PdfParadise::EmbeddableInterface.route_name?
15
+ # =========================================================================== #
16
+ module PdfParadise
17
+
18
+ module EmbeddableInterface # === PdfParadise::EmbeddableInterface
19
+
20
+ require 'pdf_paradise/constants/constants.rb'
21
+
22
+ begin
23
+ require 'cyberweb/sinatra/custom_extensions.rb'
24
+ include Cyberweb::Sinatra::CustomExtensions
25
+ rescue LoadError; end
26
+
27
+ begin
28
+ require 'html_tags'
29
+ include HtmlTags::BaseModule
30
+ rescue LoadError; end
31
+
32
+ # ========================================================================= #
33
+ # Designate a uniform CSS style to use:
34
+ # ========================================================================= #
35
+ USE_THIS_UNIFORM_CSS_STYLE = 'margin-left:3.5em; font-weight: bold;'
36
+
37
+ # ========================================================================= #
38
+ # === RARROW
39
+ # ========================================================================= #
40
+ RARROW = '→'
41
+
42
+ # ========================================================================= #
43
+ # === USE_THIS_PORT
44
+ #
45
+ # Note that this constant, for the port, is only in use when we run
46
+ # the sinatra-specific part of PdfParadise in a standalone manner.
47
+ #
48
+ # When we run from the main controller, which is part of the Roebe
49
+ # project, then this port is not relevant, as that main controller
50
+ # already handles that case.
51
+ # ========================================================================= #
52
+ USE_THIS_PORT = '5200'
53
+
54
+ # ========================================================================= #
55
+ # === @route_name
56
+ # ========================================================================= #
57
+ @route_name = ''.dup
58
+
59
+ # ========================================================================= #
60
+ # === PdfParadise::EmbeddableInterface.set_route_name
61
+ # ========================================================================= #
62
+ def self.set_route_name(i)
63
+ @route_name = i
64
+ end
65
+
66
+ # ========================================================================= #
67
+ # === PdfParadise::EmbeddableInterface.route_name?
68
+ # ========================================================================= #
69
+ def self.route_name?
70
+ @route_name
71
+ end
72
+
73
+ # ========================================================================= #
74
+ # === route_name?
75
+ # ========================================================================= #
76
+ def route_name?
77
+ ::PdfParadise::EmbeddableInterface.route_name?
78
+ end
79
+
80
+ # ========================================================================= #
81
+ # === PdfParadise::EmbeddableInterface.sub_routes?
82
+ #
83
+ # List the available sub-routes that depend on the main route_name?
84
+ # defined above. All sub-routes must be defined here, because we
85
+ # may expose this Hash to other applications.
86
+ # ========================================================================= #
87
+ def self.sub_routes?
88
+ {
89
+ view: route_name?+'/view',
90
+ n_pdf_pages: route_name?+'/n_pdf_pages'
91
+ }
92
+ end
93
+
94
+ # ========================================================================= #
95
+ # === sub_routes?
96
+ # ========================================================================= #
97
+ def sub_routes?
98
+ ::PdfParadise::EmbeddableInterface.sub_routes?
99
+ end
100
+
101
+ # ========================================================================= #
102
+ # === input_type_user_input
103
+ # ========================================================================= #
104
+ def input_type_user_input
105
+ '<input type="text" name="user_input" style="border:3px solid slateblue; padding: 4px">'
106
+ end
107
+
108
+ # ========================================================================= #
109
+ # === input_type_submit
110
+ # ========================================================================= #
111
+ def input_type_submit(
112
+ text_to_use = 'Search'
113
+ )
114
+ '<input type="submit" name="user_input_submit" value="'+text_to_use+'" class="default_submit">'
115
+ end
116
+
117
+ # ========================================================================= #
118
+ # === html_start_then_title
119
+ # ========================================================================= #
120
+ def html_start_then_title
121
+ html_start+
122
+ default_title
123
+ end; alias html_then_title html_start_then_title # === html_then_title
124
+
125
+ # ========================================================================= #
126
+ # === open_body
127
+ # ========================================================================= #
128
+ def open_body
129
+ '<body style="font-size:larger">'
130
+ end
131
+
132
+ require 'pdf_paradise/version/version.rb'
133
+ # ========================================================================= #
134
+ # === return_paragraph_of_hyperlinks
135
+ # ========================================================================= #
136
+ def return_paragraph_of_hyperlinks
137
+ p(
138
+ 'The following entry-points are available for the '\
139
+ '<b>PdfParadise project</b>: (Version: '+PdfParadise::VERSION+',
140
+ Last Update: '+PdfParadise::LAST_UPDATE+')
141
+ <br><br>'+
142
+ return_index_of_hyperlinks
143
+ )
144
+ end; alias footer return_paragraph_of_hyperlinks # === footer (footer tag)
145
+
146
+ # ========================================================================= #
147
+ # === return_link_to_root
148
+ # ========================================================================= #
149
+ def return_link_to_root
150
+ a(
151
+ '/',
152
+ content: :self,
153
+ css_style: USE_THIS_UNIFORM_CSS_STYLE
154
+ )+
155
+ '<br>'
156
+ end
157
+
158
+ # ========================================================================= #
159
+ # === return_view_string
160
+ # ========================================================================= #
161
+ def return_view_string
162
+ hash = PdfParadise::EmbeddableInterface.sub_routes?
163
+ h1('Pdf Options:', css_style: 'margin-left:0.25em;')+
164
+ p(
165
+ "The next link is to view all .pdf files at <b>"\
166
+ "#{PdfParadise.main_directory?}</b>"
167
+ )+
168
+ a(hash[:view])+'<br>'
169
+ end; alias view? return_view_string # === view?
170
+
171
+ # ========================================================================= #
172
+ # === return_index_of_hyperlinks
173
+ #
174
+ # This method will bundle together the different indices containing the
175
+ # hyperlinks that will be shown on the root-directory.
176
+ # ========================================================================= #
177
+ def return_index_of_hyperlinks
178
+ # ======================================================================= #
179
+ # Obtain the hash that keeps track of all routes.
180
+ # ======================================================================= #
181
+ hash = PdfParadise::EmbeddableInterface.sub_routes?
182
+
183
+ if Object.const_defined? :WebObject
184
+ cat_image = WebObject.base64_image(:cat)
185
+ else
186
+ cat_image = ''
187
+ end
188
+ a('/', content: cat_image+' /',
189
+ css_style: USE_THIS_UNIFORM_CSS_STYLE)+
190
+ '<br>'+
191
+ a(hash[:view], content: cat_image+' /view',
192
+ css_style: USE_THIS_UNIFORM_CSS_STYLE)+
193
+ '<br>'+
194
+ a(hash[:n_pdf_pages], content: cat_image+' /n_pdf_pages',
195
+ css_style: USE_THIS_UNIFORM_CSS_STYLE)+
196
+ '<br>'+
197
+ a('/title', content: cat_image+' /title',
198
+ css_style: USE_THIS_UNIFORM_CSS_STYLE)+
199
+ '<br>'+
200
+ # ======================================================================= #
201
+ # Explain the autoconvert option a little bit:
202
+ # ======================================================================= #
203
+ p(
204
+ 'Click on the <b>following link</b> to autoconvert all .pdf files '\
205
+ 'in the directory called '\
206
+ '<b>'+PdfParadise.main_directory?.to_s+'</b>'
207
+ )+
208
+ a('/autoconvert', css_style: USE_THIS_UNIFORM_CSS_STYLE)+
209
+ '<br>'+
210
+ return_div_for_manual_pdf_conversion
211
+ end; alias return_the_hyperlinks return_index_of_hyperlinks # === return_the_hyperlinks
212
+
213
+ # ========================================================================= #
214
+ # === return_div_for_manual_pdf_conversion
215
+ # ========================================================================= #
216
+ def return_div_for_manual_pdf_conversion
217
+ # ======================================================================= #
218
+ # Determine the main route for the upcoming action:
219
+ # ======================================================================= #
220
+ route_to_this_action = '/convert_single_pdf_file/'
221
+ # ======================================================================= #
222
+ # Add the <div> that contains the manual conversion functionality:
223
+ # ======================================================================= #
224
+ # ======================================================================= #
225
+ # Explain how to convert just an individual file instead:
226
+ # ======================================================================= #
227
+ p('If you merely wish to convert a single .pdf file, you can use '\
228
+ 'the following form for this:')+
229
+ div(css_style: 'padding: 0.2em') {
230
+ p(
231
+ '<b>Enter the name of the .pdf file that you wish to convert:</b>', css_style: 'padding:0.75em'
232
+ )+
233
+ form(action: route_to_this_action,
234
+ id: 'convert_single_pdf_file',
235
+ css_style: 'margin-left:2em; margin-top:2px') {
236
+ '<input type="text" name="user_input" style="border:3px solid slateblue; padding: 4px"><br>'\
237
+ '<b>Select a file</b>: <input type="file" name="this_file"><br>'\
238
+ '<input type="submit" name="user_input_submit" '\
239
+ 'value="Click here to convert the .pdf file" style="2px dotted royalblue; '\
240
+ 'color: white; background-color: olive; font-size: 1.50em;
241
+ margin:4px; padding: 4px; border: 1px solid black">'
242
+ }
243
+ }
244
+ end
245
+
246
+ # ========================================================================= #
247
+ # === close_html
248
+ # ========================================================================= #
249
+ def close_html
250
+ '</html>'
251
+ end
252
+
253
+ # ========================================================================= #
254
+ # === open_html
255
+ # ========================================================================= #
256
+ def open_html
257
+ '<html>'
258
+ end; alias html_start open_html # === html_start
259
+
260
+ # ========================================================================= #
261
+ # === return_full_title
262
+ # ========================================================================= #
263
+ def return_full_title
264
+ '<title>PDF-based operations</title>'
265
+ end; alias default_title return_full_title # === default_title
266
+
267
+ # ========================================================================= #
268
+ # === close_body
269
+ # ========================================================================= #
270
+ def close_body
271
+ '</body>'
272
+ end
273
+
274
+ # ========================================================================= #
275
+ # === return_root_string
276
+ # ========================================================================= #
277
+ def return_root_string
278
+ html_then_title+
279
+ open_body+
280
+ return_paragraph_of_hyperlinks+
281
+ close_body+
282
+ close_html
283
+ end
284
+
285
+ # =========================================================================== #
286
+ # === return_n_pdf_pages
287
+ # =========================================================================== #
288
+ def return_n_pdf_pages
289
+ route_to_this_action = sub_routes?[:n_pdf_pages]
290
+ html_start_then_title+
291
+ p('Provide the path to a .pdf file:')+
292
+ form(action: route_to_this_action,
293
+ id: route_to_this_action.delete('/'),
294
+ css_style: 'margin-left:2em; margin-top:2px') {
295
+ input_type_user_input+
296
+ br+
297
+ input_type_submit('Submit')
298
+ }
299
+ end
300
+
301
+ end
302
+
303
+ # =========================================================================== #
304
+ # === PdfParadise.embeddable_interface
305
+ #
306
+ # This method can be used to "embed" a fake-object that implements the
307
+ # module defined above.
308
+ # =========================================================================== #
309
+ def self.embeddable_interface
310
+ object = Object.new
311
+ object.extend(PdfParadise::EmbeddableInterface)
312
+ return object
313
+ end
314
+
315
+ end
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'pdf_paradise/toplevel_methods/automatic_pdf_title.rb'
6
+ # PdfParadise.autotitle(ARGV)
7
+ # =========================================================================== #
8
+ module PdfParadise
9
+
10
+ begin
11
+ require 'colours'
12
+ rescue LoadError; end
13
+
14
+ require 'pdf_paradise/toplevel_methods/e.rb'
15
+ require 'pdf_paradise/set_pdf_title.rb'
16
+
17
+ # ========================================================================= #
18
+ # === PdfParadise.automatic_pdf_title
19
+ #
20
+ # This method will automatically set the title of a .pdf file to its
21
+ # filename, with all '_' tokens replaced by ' ' tokens.
22
+ #
23
+ # The input to this method should be .pdf files that are existing locally.
24
+ # ========================================================================= #
25
+ def self.automatic_pdf_title(i)
26
+ i = [i].flatten.compact
27
+ i.each {|this_pdf_file|
28
+ if File.exist? this_pdf_file
29
+ new_pdf_title = File.basename(this_pdf_file).sub(/#{File.extname(this_pdf_file)}$/,'').tr('_',' ')
30
+ # =================================================================== #
31
+ # Remove leading 'DONE_' substrings:
32
+ # =================================================================== #
33
+ if new_pdf_title.start_with? 'DONE'
34
+ new_pdf_title.sub!(/^DONE_/,'') if new_pdf_title.include? 'DONE_'
35
+ new_pdf_title.sub!(/^DONE /,'') if new_pdf_title.include? 'DONE '
36
+ end
37
+ e "#{Colours.rev}Setting the title of the .pdf file "\
38
+ "#{Colours.sfile(this_pdf_file)} to:"
39
+ e
40
+ e " #{new_pdf_title}"
41
+ e
42
+ set_pdf_title(
43
+ this_pdf_file, new_pdf_title # First comes the file, then the title.
44
+ )
45
+ else
46
+ e 'No .pdf file exists at `'+sfile(this_pdf_file)+'`.'
47
+ end
48
+ }
49
+ end; self.instance_eval { alias autotitle automatic_pdf_title } # === PdfParadise.autotitle
50
+
51
+ end
52
+
53
+ if __FILE__ == $PROGRAM_NAME
54
+ PdfParadise.automatic_pdf_title(ARGV)
55
+ end # apdf
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module PdfParadise
6
+
7
+ require 'pdf_paradise/toplevel_methods/esystem.rb'
8
+
9
+ # ========================================================================= #
10
+ # === PdfParadise.convert_epub_to_pdf
11
+ #
12
+ # This method allows us to convert an .epub file to .pdf format, if
13
+ # pandoc is available.
14
+ # ========================================================================= #
15
+ def self.convert_epub_to_pdf(i)
16
+ i = [i].flatten.compact
17
+ i.each {|entry|
18
+ _ = 'pandoc -s -t latex --toc --chapters --latex-engine=lualatex '+entry+' -o '+entry+'.pdf'
19
+ esystem _
20
+ }
21
+ end
22
+
23
+ end
24
+
25
+ if __FILE__ == $PROGRAM_NAME
26
+ PdfParadise.convert_epub_to_pdf(ARGV)
27
+ end
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'pdf_paradise/toplevel_methods/convert_markdown_to_pdf.rb'
6
+ # =========================================================================== #
7
+ module PdfParadise
8
+
9
+ require 'pdf_paradise/toplevel_methods/e.rb'
10
+
11
+ # ========================================================================= #
12
+ # === PdfParadise.convert_markdown_to_pdf
13
+ #
14
+ # This method can be used to convert a markdown .md file into a .pdf
15
+ # file.
16
+ #
17
+ # This functionality depends on kramdown, and kramdown-pdf-converter.
18
+ # ========================================================================= #
19
+ def self.convert_markdown_to_pdf(
20
+ this_markdown_file
21
+ )
22
+ require 'kramdown'
23
+ require 'kramdown/converter/pdf'
24
+ require 'save_file'
25
+ require 'colours'
26
+ [this_markdown_file].flatten.compact.each {|markdown_file|
27
+ if File.exist? markdown_file
28
+ text = File.read(markdown_file)
29
+ dataset = Kramdown::Document.new(text).to_pdf
30
+ target = markdown_file.sub(/#{File.extname(markdown_file)}$/,'')+'.pdf'
31
+ e 'Storing into the file `'+Colours.sfile(target)+'`.'
32
+ SaveFile.write_what_into(dataset, target)
33
+ else
34
+ e 'No file exists at '+Colours.sfile(markdown_file)+'.'
35
+ end
36
+ }
37
+ end
38
+
39
+ end
40
+
41
+ if __FILE__ == $PROGRAM_NAME
42
+ PdfParadise.convert_markdown_to_pdf(ARGV)
43
+ end # convert_markdown_to_pdf
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'pdf_paradise/toplevel_methods/convert_ppt_to_pdf.rb'
6
+ # =========================================================================== #
7
+ require 'pdf_paradise/toplevel_methods/esystem.rb'
8
+
9
+ module PdfParadise
10
+
11
+ # ========================================================================= #
12
+ # === PdfParadise.convert_this_ppt_file_to_a_pdf_file
13
+ #
14
+ # This method will make use of libreoffice to convert .pptx or
15
+ # ppt files into .pdf files.
16
+ # ========================================================================= #
17
+ def self.convert_this_ppt_file_to_a_pdf_file(
18
+ i, use_this_format = 'pptx'
19
+ )
20
+ if i.is_a? Array
21
+ i.each {|entry|
22
+ convert_this_ppt_file_to_a_pdf_file(entry, use_this_format)
23
+ }
24
+ else
25
+ cmd = 'libreoffice --headless --invisible --convert-to pdf *.'+use_this_format
26
+ esystem cmd
27
+ end
28
+ end; self.instance_eval { alias convert_ppt_to_pdf convert_this_ppt_file_to_a_pdf_file } # === PdfParadise.convert_ppt_to_pdf
29
+ self.instance_eval { alias convert_pptx_to_pdf convert_this_ppt_file_to_a_pdf_file } # === PdfParadise.convert_pptx_to_pdf
30
+
31
+ end
32
+
33
+ if __FILE__ == $PROGRAM_NAME
34
+ PdfParadise.convert_this_ppt_file_to_a_pdf_file(ARGV)
35
+ end