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,233 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === PdfParadise::GUI::Libui::StatisticsWidget
6
+ # =========================================================================== #
7
+ # require 'pdf_paradise/gui/libui/statistics_widget/statistics_widget.rb'
8
+ # PdfParadise::GUI::Libui::StatisticsWidget.new
9
+ # =========================================================================== #
10
+ module PdfParadise
11
+
12
+ module GUI
13
+
14
+ module Libui
15
+
16
+ class StatisticsWidget # === PdfParadise::GUI::Libui::StatisticsWidget
17
+
18
+ require 'libui_paradise/autoinclude'
19
+
20
+ require 'pdf_paradise/pdf_file_n_total_pages.rb'
21
+ require 'pdf_paradise/toplevel_methods/automatic_pdf_title.rb'
22
+ require 'pdf_paradise/toplevel_methods/query_pdf_title.rb'
23
+
24
+ begin
25
+ require 'colours'
26
+ rescue LoadError; end
27
+
28
+ # ========================================================================= #
29
+ # === TITLE
30
+ # ========================================================================= #
31
+ TITLE = 'Show statistics about the .pdf file at hand'
32
+
33
+ # ========================================================================= #
34
+ # === initialize
35
+ # ========================================================================= #
36
+ def initialize
37
+ reset
38
+ create_skeleton
39
+ # ======================================================================= #
40
+ # === @main_window
41
+ # ======================================================================= #
42
+ @main_window = ui_main_window(
43
+ TITLE, 560, 240, 0
44
+ )
45
+ outer_vbox = ui_padded_vbox
46
+
47
+ # ======================================================================= #
48
+ # === First row
49
+ # ======================================================================= #
50
+ hbox = ui_padded_hbox
51
+ @button_auto_title = ui_button('Automatic Title')
52
+ @button_auto_title.on_clicked {
53
+ do_automatically_determine_the_title_for_the_pdf_file_at_hand
54
+ }
55
+ hbox.minimal(@button_auto_title)
56
+ @button_open_via_a_pdf_reader = ui_button('Open via a pdf-reader')
57
+ @button_open_via_a_pdf_reader.on_clicked {
58
+ do_open_the_local_pdf_file_in_the_pdf_reader
59
+ }
60
+ hbox.minimal(@button_open_via_a_pdf_reader)
61
+ hbox.minimal(ui_quit_button)
62
+ outer_vbox.minimal(hbox)
63
+
64
+ # ======================================================================= #
65
+ # === Second row
66
+ # ======================================================================= #
67
+ outer_vbox.minimal(
68
+ text(
69
+ 'This small widget will show some information about '\
70
+ 'the .pdf file at hand.'
71
+ )
72
+ )
73
+ # ======================================================================= #
74
+ # === Third row
75
+ # ======================================================================= #
76
+ hbox = ui_padded_hbox
77
+ hbox.minimal(left_arrow?)
78
+ hbox.maximal(@entry_use_this_pdf_file)
79
+ outer_vbox.maximal(hbox)
80
+
81
+ # ======================================================================= #
82
+ # === Fourth row
83
+ # ======================================================================= #
84
+ hbox = ui_padded_hbox
85
+ button_open_file = ui_button('Open File')
86
+ button_open_file.on_clicked {
87
+ begin
88
+ @filename = ui_open_file(@main_window).to_s # This is the part that will open a local file.
89
+ rescue Exception => error
90
+ @filename = nil # To prevent "Null pointer given" errors.
91
+ # =================================================================== #
92
+ # The error specifically is:
93
+ #
94
+ # #<ArgumentError: NULL pointer given>
95
+ #
96
+ # =================================================================== #
97
+ end
98
+ if @filename and File.exist?(@filename)
99
+ @entry_use_this_pdf_file.set_text(@filename)
100
+ end
101
+ }
102
+ hbox.minimal(button_open_file)
103
+ # ======================================================================= #
104
+ # === button_analyse_the_pdf_file
105
+ # ======================================================================= #
106
+ button_analyse_the_pdf_file = ui_button('Analyse the .pdf file')
107
+ button_analyse_the_pdf_file.on_clicked {
108
+ e 'TODO Analyse the pdf file'
109
+ }
110
+ hbox.minimal(button_analyse_the_pdf_file)
111
+ outer_vbox.minimal(hbox)
112
+
113
+ # ======================================================================= #
114
+ # === Fifth row
115
+ # ======================================================================= #
116
+ @label = ui_text
117
+ outer_vbox.minimal(@label)
118
+ @main_window.child = outer_vbox
119
+ @main_window.intelligent_exit
120
+ end
121
+
122
+ # ========================================================================= #
123
+ # === reset (reset tag)
124
+ # ========================================================================= #
125
+ def reset
126
+ # ======================================================================= #
127
+ # === @filename
128
+ # ======================================================================= #
129
+ @filename = nil
130
+ end
131
+
132
+ # ========================================================================= #
133
+ # === create_skeleton
134
+ # ========================================================================= #
135
+ def create_skeleton
136
+ create_all_entries
137
+ create_all_buttons
138
+ end
139
+
140
+ # ========================================================================= #
141
+ # === create_all_entries
142
+ # ========================================================================= #
143
+ def create_all_entries
144
+ # ======================================================================= #
145
+ # === @entry_use_this_pdf_file
146
+ # ======================================================================= #
147
+ @entry_use_this_pdf_file = ui_entry
148
+ end
149
+
150
+ # ========================================================================= #
151
+ # === main_entry?
152
+ # ========================================================================= #
153
+ def main_entry?
154
+ @entry_use_this_pdf_file
155
+ end
156
+
157
+ # ========================================================================= #
158
+ # === do_automatically_determine_the_title_for_the_pdf_file_at_hand
159
+ # ========================================================================= #
160
+ def do_automatically_determine_the_title_for_the_pdf_file_at_hand(
161
+ this_pdf_file = main_entry?.text?
162
+ )
163
+ if this_pdf_file and !this_pdf_file.empty?
164
+ ::PdfParadise.automatic_pdf_title(this_pdf_file)
165
+ do_analyse_the_pdf_file
166
+ else
167
+ popup_over_this_widget(
168
+ @main_window,
169
+ 'Please first assign a .pdf file, before '\
170
+ 'this functionality can be used.'
171
+ )
172
+ end
173
+ end
174
+
175
+ # ========================================================================= #
176
+ # === do_analyse_the_pdf_file
177
+ #
178
+ # This is the method that will analyse the .pdf file at hand.
179
+ # ========================================================================= #
180
+ def do_analyse_the_pdf_file(
181
+ this_pdf_file = main_entry?.text.to_s
182
+ )
183
+ _ = ''.dup
184
+ _ << "This .pdf file has the following characteristics:\n\n"
185
+ _ << ' <b>n pages</b>: '+::PdfParadise.n_pages?(this_pdf_file).to_s
186
+ _ << "\n"
187
+ use_this_title = ::PdfParadise.title?(this_pdf_file).to_s
188
+ if use_this_title.empty?
189
+ use_this_title = '(This .pdf file has no title)'
190
+ end
191
+ _ << " <b>title</b>: #{use_this_title}"
192
+ _ << "\n"
193
+ @label.set_text(_)
194
+ end
195
+
196
+ # ========================================================================= #
197
+ # === do_open_the_local_pdf_file_in_the_pdf_reader
198
+ # ========================================================================= #
199
+ def do_open_the_local_pdf_file_in_the_pdf_reader(
200
+ this_pdf_file = main_entry?.text?
201
+ )
202
+ if this_pdf_file and !this_pdf_file.empty?
203
+ Thread.new {
204
+ esystem("evince #{this_pdf_file}")
205
+ }
206
+ else
207
+ popup_over_this_widget(
208
+ @main_window,
209
+ 'Please first assign a .pdf file, before '\
210
+ 'this functionality can be used.'
211
+ )
212
+ end
213
+ end
214
+
215
+ # ========================================================================= #
216
+ # === esystem
217
+ # ========================================================================= #
218
+ def esystem(i)
219
+ e i
220
+ system i
221
+ end
222
+
223
+ # ========================================================================= #
224
+ # === create_all_buttons
225
+ # ========================================================================= #
226
+ def create_all_buttons
227
+ end
228
+
229
+ end; end; end; end
230
+
231
+ if __FILE__ == $PROGRAM_NAME
232
+ PdfParadise::GUI::Libui::StatisticsWidget.new
233
+ end
@@ -0,0 +1,277 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === PdfParadise::GUI::Gtk::ConvertPdfToTextModule
6
+ # =========================================================================== #
7
+ # require 'pdf_paradise/gui/shared_code/convert_pdf_to_text/convert_pdf_to_text_module.rb'
8
+ # include ::PdfParadise::GUI::Gtk::ConvertPdfToTextModule
9
+ # =========================================================================== #
10
+ module PdfParadise
11
+
12
+ module GUI
13
+
14
+ module Gtk
15
+
16
+ module ConvertPdfToTextModule
17
+
18
+ require 'pdf_paradise/utility_scripts/convert_pdf_to_text.rb'
19
+
20
+ require 'gtk_paradise/requires/require_the_base_module.rb'
21
+ include ::Gtk::BaseModule
22
+
23
+ # ========================================================================= #
24
+ # === NAMESPACE
25
+ # ========================================================================= #
26
+ NAMESPACE = inspect
27
+
28
+ # ========================================================================= #
29
+ # === TITLE
30
+ # ========================================================================= #
31
+ TITLE = 'Convert .pdf to text-file'
32
+
33
+ # ========================================================================= #
34
+ # === WIDTH
35
+ # ========================================================================= #
36
+ WIDTH = 1280
37
+
38
+ # ========================================================================= #
39
+ # === HEIGHT
40
+ # ========================================================================= #
41
+ HEIGHT = 580
42
+
43
+ # ========================================================================= #
44
+ # === USE_THIS_FONT
45
+ # ========================================================================= #
46
+ USE_THIS_FONT = :dejavu_condensed_22
47
+
48
+ # ========================================================================= #
49
+ # === initialize
50
+ # ========================================================================= #
51
+ def initialize(
52
+ commandline_arguments = ARGV,
53
+ run_already = true
54
+ )
55
+ super(:vertical)
56
+ reset
57
+ set_commandline_arguments(
58
+ commandline_arguments
59
+ )
60
+ run if run_already
61
+ end
62
+
63
+ # ========================================================================= #
64
+ # === reset (reset tag)
65
+ # ========================================================================= #
66
+ def reset
67
+ reset_the_internal_variables
68
+ # ======================================================================= #
69
+ # === @configuration
70
+ # ======================================================================= #
71
+ @configuration = [true, __dir__, NAMESPACE]
72
+ # ======================================================================= #
73
+ # === @title
74
+ # ======================================================================= #
75
+ @title = TITLE
76
+ # ======================================================================= #
77
+ # === @width
78
+ # ======================================================================= #
79
+ set_width(WIDTH)
80
+ # ======================================================================= #
81
+ # === @height
82
+ # ======================================================================= #
83
+ set_height(HEIGHT)
84
+ set_use_this_font(USE_THIS_FONT)
85
+ use_project_css_file # or use use_gtk_paradise_project_css_file
86
+ infer_the_size_automatically
87
+ end
88
+
89
+ # ========================================================================= #
90
+ # === padding?
91
+ # ========================================================================= #
92
+ def padding?
93
+ 2
94
+ end
95
+
96
+ # ========================================================================= #
97
+ # === border_size?
98
+ # ========================================================================= #
99
+ def border_size?
100
+ 1
101
+ end
102
+
103
+ # ========================================================================= #
104
+ # === return_the_open_pdf_file_button
105
+ # ========================================================================= #
106
+ def return_the_open_pdf_file_button
107
+ @button_open_pdf_file
108
+ end
109
+
110
+ # ========================================================================= #
111
+ # === create_buttons
112
+ # ========================================================================= #
113
+ def create_buttons
114
+ # ======================================================================= #
115
+ # === Create the open-file-button
116
+ # ======================================================================= #
117
+ @button_open_pdf_file = gtk_button('Open File')
118
+ @button_open_pdf_file.hint = 'Click on this button '\
119
+ 'in order to open a local .pdf file.'
120
+ @button_open_pdf_file.on_clicked {
121
+ do_open_a_local_pdf_file
122
+ }
123
+ end
124
+
125
+ # ========================================================================= #
126
+ # === create_skeleton (create tag)
127
+ # ========================================================================= #
128
+ def create_skeleton
129
+ create_buttons
130
+ create_the_scrolled_window_with_the_text_buffer
131
+ create_the_entry
132
+ end
133
+
134
+ # ========================================================================= #
135
+ # === create_the_entry
136
+ # ========================================================================= #
137
+ def create_the_entry
138
+ # ======================================================================= #
139
+ # === @entry_convert_pdf_to_text
140
+ # ======================================================================= #
141
+ @entry_convert_pdf_to_text = gtk_entry
142
+ @entry_convert_pdf_to_text.width_height(600, 42)
143
+ @entry_convert_pdf_to_text.yellow_background
144
+ @entry_convert_pdf_to_text.set_text(
145
+ '/Depot/PDF/foobar.pdf'
146
+ )
147
+ @entry_convert_pdf_to_text.enable_scroll_events
148
+ # ======================================================================= #
149
+ # Let this entry respond to mouse-scroll-events, e. g. the user does
150
+ # some scrolling via the mouse-wheel.
151
+ # ======================================================================= #
152
+ @entry_convert_pdf_to_text.on_mouse_scroll_event {|widget, event|
153
+ this_file = @entry_convert_pdf_to_text.text?
154
+ base_dir = "#{File.dirname(this_file)}/"
155
+ array_pdf_entries = Dir[base_dir+'*.pdf']
156
+ # ===================================================================== #
157
+ # Next, determine the position.
158
+ # ===================================================================== #
159
+ index = array_pdf_entries.index(this_file)
160
+ if index
161
+ if scroll_up?(event) # Scroll up.
162
+ index -= 1 unless index == 0
163
+ elsif scroll_down?(event) # Scroll down.
164
+ index += 1 unless index >= (array_pdf_entries.size - 1)
165
+ end
166
+ this_file = array_pdf_entries[index]
167
+ @entry_convert_pdf_to_text.set_text(this_file)
168
+ end
169
+ }
170
+ end
171
+
172
+ # ========================================================================= #
173
+ # === create_the_scrolled_window_with_the_text_buffer
174
+ # ========================================================================= #
175
+ def create_the_scrolled_window_with_the_text_buffer
176
+ @text_buffer = gtk_text_buffer
177
+ text_view = gtk_text_view(@text_buffer)
178
+ @scrolled_window = gtk_scrolled_window(text_view) { :always }
179
+ @scrolled_window.width_height(600, 560)
180
+ @scrolled_window.bblack1
181
+ end
182
+
183
+ # ========================================================================= #
184
+ # === connect_skeleton (connect tag)
185
+ # ========================================================================= #
186
+ def connect_skeleton
187
+ abort_on_exception
188
+ hbox = gtk_hbox
189
+ hbox.minimal(
190
+ text('Convert this <b>.pdf</b> file to text:'), 4
191
+ )
192
+ hbox.minimal(@entry_convert_pdf_to_text, 5)
193
+ hbox.minimal(return_the_open_pdf_file_button, 4)
194
+ minimal(hbox, 2)
195
+ # ======================================================================= #
196
+ # === button_do_the_conversion
197
+ # ======================================================================= #
198
+ button_do_the_conversion = gtk_button('_Convert')
199
+ button_do_the_conversion.bblack1
200
+ button_do_the_conversion.hint = 'Click this button '\
201
+ 'to <b>convert the .pdf file into a text-file</b>.'
202
+ button_do_the_conversion.on_click {
203
+ do_the_conversion
204
+ }
205
+ minimal(button_do_the_conversion, 2)
206
+ minimal(@scrolled_window, 5)
207
+ end
208
+
209
+ # ========================================================================= #
210
+ # === set_filepath
211
+ # ========================================================================= #
212
+ def set_filepath(i)
213
+ @entry_convert_pdf_to_text.set_text(i.to_s)
214
+ end
215
+
216
+ # ========================================================================= #
217
+ # === do_the_conversion (conversion tag)
218
+ # ========================================================================= #
219
+ def do_the_conversion
220
+ _ = @entry_convert_pdf_to_text.text?
221
+ if _ and File.exist?(_)
222
+ result = PdfParadise::ConvertPdfToText.new(_)
223
+ output_file = result.output_file?
224
+ if File.exist?(output_file)
225
+ @text_buffer.set_text(
226
+ File.read(output_file).to_s
227
+ )
228
+ end
229
+ else
230
+ popover(
231
+ 'Please specify a local, existing .pdf file.',
232
+ use_this_widget: @entry_convert_pdf_to_text,
233
+ font_to_use: :hack_20
234
+ ).popup
235
+ end
236
+ end
237
+
238
+ # ========================================================================= #
239
+ # === run (run tag)
240
+ # ========================================================================= #
241
+ def run
242
+ create_skeleton_then_connect_skeleton
243
+ end
244
+
245
+ # ========================================================================= #
246
+ # === do_open_a_local_pdf_file
247
+ # ========================================================================= #
248
+ def do_open_a_local_pdf_file
249
+ # ======================================================================= #
250
+ # Create the particular file-chooser widget that we wish to use.
251
+ # ======================================================================= #
252
+ create_a_new_file_chooser_dialog(self) {{
253
+ start_dir: return_pwd,
254
+ filter_for: :pdf_files,
255
+ additional_directories: '/Depot/PDF/'
256
+ }}
257
+ _ = ::Gtk.main_file?
258
+ set_filepath(_)
259
+ do_the_conversion
260
+ end
261
+
262
+ # ========================================================================= #
263
+ # === PdfParadise::GUI::Gtk::ConvertPdfToTextModule.run
264
+ # ========================================================================= #
265
+ def self.run(
266
+ i = ARGV
267
+ )
268
+ require 'gtk_paradise/run'
269
+ _ = ::PdfParadise::GUI::Gtk::ConvertPdfToText.new(i)
270
+ r = ::Gtk.run
271
+ r << _
272
+ r.automatic_size
273
+ r.automatic_title
274
+ r.top_left_then_run
275
+ end
276
+
277
+ end; end; end; end