pdf_paradise 0.3.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +933 -0
  3. data/bin/automatic_pdf_title +7 -0
  4. data/bin/burst_this_pdf_file +7 -0
  5. data/bin/combine_these_pdf_pages +7 -0
  6. data/bin/compress_via_hexapdf +7 -0
  7. data/bin/convert_markdown_to_pdf +7 -0
  8. data/bin/convert_pdf_to_text +7 -0
  9. data/bin/delete_first_page_of_this_pdf_file +7 -0
  10. data/bin/djvu_to_pdf +7 -0
  11. data/bin/merge_then_open +7 -0
  12. data/bin/n_pages +10 -0
  13. data/bin/open_main_pdf +7 -0
  14. data/bin/pdf_paradise +9 -0
  15. data/bin/rotate_pdf +7 -0
  16. data/bin/set_main_book +7 -0
  17. data/bin/set_title_of_this_pdf_file +15 -0
  18. data/doc/README.gen +871 -0
  19. data/doc/todo/todo.md +13 -0
  20. data/images/Logo_for_the_pdf_paradise_project.avif +0 -0
  21. data/lib/pdf_paradise/base/base.rb +344 -0
  22. data/lib/pdf_paradise/base/colours.rb +67 -0
  23. data/lib/pdf_paradise/colours/colours.rb +27 -0
  24. data/lib/pdf_paradise/commandline/commandline.rb +109 -0
  25. data/lib/pdf_paradise/commandline/help.rb +77 -0
  26. data/lib/pdf_paradise/commandline/menu.rb +173 -0
  27. data/lib/pdf_paradise/compress/compress_this_pdf_file.rb +108 -0
  28. data/lib/pdf_paradise/compress/compress_via_hexapdf.rb +27 -0
  29. data/lib/pdf_paradise/compress/compress_via_qpdf.rb +32 -0
  30. data/lib/pdf_paradise/constants/constants.rb +76 -0
  31. data/lib/pdf_paradise/convert_text_to_pdf.rb +94 -0
  32. data/lib/pdf_paradise/css/project.css +17 -0
  33. data/lib/pdf_paradise/fpdf/README.md +2 -0
  34. data/lib/pdf_paradise/fpdf/bookmark.rb +129 -0
  35. data/lib/pdf_paradise/fpdf/chinese.rb +454 -0
  36. data/lib/pdf_paradise/fpdf/fpdf.rb +1902 -0
  37. data/lib/pdf_paradise/fpdf/fpdf_eps.rb +138 -0
  38. data/lib/pdf_paradise/fpdf/makefont.rb +1794 -0
  39. data/lib/pdf_paradise/gui/README.md +6 -0
  40. data/lib/pdf_paradise/gui/fox/split_pdf_file.rb +77 -0
  41. data/lib/pdf_paradise/gui/gtk2/pdf_viewer/pdf_viewer.rb +34 -0
  42. data/lib/pdf_paradise/gui/gtk2/split_pdf_file/split_pdf_file.rb +34 -0
  43. data/lib/pdf_paradise/gui/gtk2/statistics_widget/statistics_widget.rb +34 -0
  44. data/lib/pdf_paradise/gui/gtk3/controller/controller.rb +214 -0
  45. data/lib/pdf_paradise/gui/gtk3/pdf_viewer/pdf_viewer.rb +34 -0
  46. data/lib/pdf_paradise/gui/gtk3/split_pdf_file/split_pdf_file.rb +34 -0
  47. data/lib/pdf_paradise/gui/jruby/delete_the_first_or_the_last_page_of_this_pdf_file/delete_the_first_or_the_last_page_of_this_pdf_file.rb +167 -0
  48. data/lib/pdf_paradise/gui/jruby/remove_the_first_page_of_this_pdf_file/remove_the_first_page_of_this_pdf_file.rb +103 -0
  49. data/lib/pdf_paradise/gui/libui/extract_all_images_from_this_pdf_file/extract_all_images_from_this_pdf_file.rb +223 -0
  50. data/lib/pdf_paradise/gui/libui/remove_the_first_page_of_this_pdf_file/remove_the_first_page_of_this_pdf_file.rb +267 -0
  51. data/lib/pdf_paradise/gui/libui/rotate_pdf_file/rotate_pdf_file.rb +219 -0
  52. data/lib/pdf_paradise/gui/libui/statistics_widget/statistics_widget.rb +233 -0
  53. data/lib/pdf_paradise/gui/shared_code/pdf_viewer/pdf_viewer.css +5 -0
  54. data/lib/pdf_paradise/gui/shared_code/pdf_viewer/pdf_viewer_module.rb +287 -0
  55. data/lib/pdf_paradise/gui/shared_code/remove_the_first_page_of_this_pdf_file_module/remove_the_first_page_of_this_pdf_file_module.rb +31 -0
  56. data/lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb +295 -0
  57. data/lib/pdf_paradise/gui/universal_widgets/convert_pdf_to_text/convert_pdf_to_text.rb +366 -0
  58. data/lib/pdf_paradise/gui/universal_widgets/delete_the_first_or_the_last_page_of_this_pdf_file/delete_the_first_or_the_last_page_of_this_pdf_file.rb +776 -0
  59. data/lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb +407 -0
  60. data/lib/pdf_paradise/gui/universal_widgets/to_pdf/to_pdf.rb +351 -0
  61. data/lib/pdf_paradise/hexapdf/001_rainbow_pattern_example.rb +0 -0
  62. data/lib/pdf_paradise/hexapdf/hexapdf.rb +123 -0
  63. data/lib/pdf_paradise/images/PDF_PARADISE_LOGO.png +0 -0
  64. data/lib/pdf_paradise/main_pdf/main_pdf.rb +474 -0
  65. data/lib/pdf_paradise/merge_pdf/menu.rb +63 -0
  66. data/lib/pdf_paradise/merge_pdf/merge_pdf.rb +307 -0
  67. data/lib/pdf_paradise/merge_pdf_namespace.rb +9 -0
  68. data/lib/pdf_paradise/merge_then_open/merge_then_open.rb +105 -0
  69. data/lib/pdf_paradise/prawn_addons/README.md +2 -0
  70. data/lib/pdf_paradise/prawn_addons/prawn_addons.rb +17 -0
  71. data/lib/pdf_paradise/project/project.rb +22 -0
  72. data/lib/pdf_paradise/remove_pdf_password.rb +391 -0
  73. data/lib/pdf_paradise/requires/batch_require_toplevel_files.rb +22 -0
  74. data/lib/pdf_paradise/requires/colours.rb +11 -0
  75. data/lib/pdf_paradise/requires/colours_and_esystem_and_save_file_and_fileutils_and_opn.rb +13 -0
  76. data/lib/pdf_paradise/requires/esystem_and_colours.rb +11 -0
  77. data/lib/pdf_paradise/requires/esystem_and_opn_and_colours.rb +10 -0
  78. data/lib/pdf_paradise/requires/require_the_whole_project.rb +30 -0
  79. data/lib/pdf_paradise/requires/require_utility_scripts.rb +9 -0
  80. data/lib/pdf_paradise/set_main_book.rb +156 -0
  81. data/lib/pdf_paradise/set_pdf_title.rb +220 -0
  82. data/lib/pdf_paradise/sinatra/embeddable_interface.rb +389 -0
  83. data/lib/pdf_paradise/toplevel_methods/convert_epub_to_pdf.rb +27 -0
  84. data/lib/pdf_paradise/toplevel_methods/convert_markdown_to_pdf.rb +45 -0
  85. data/lib/pdf_paradise/toplevel_methods/convert_ppt_to_pdf.rb +35 -0
  86. data/lib/pdf_paradise/toplevel_methods/e.rb +16 -0
  87. data/lib/pdf_paradise/toplevel_methods/esystem.rb +20 -0
  88. data/lib/pdf_paradise/toplevel_methods/misc.rb +228 -0
  89. data/lib/pdf_paradise/toplevel_methods/number_pages.rb +38 -0
  90. data/lib/pdf_paradise/toplevel_methods/opened_pdf_files.rb +221 -0
  91. data/lib/pdf_paradise/toplevel_methods/query_pdf_title.rb +201 -0
  92. data/lib/pdf_paradise/toplevel_methods/reduce_size_of_this_pdf_file.rb +46 -0
  93. data/lib/pdf_paradise/toplevel_methods/roebe.rb +17 -0
  94. data/lib/pdf_paradise/toplevel_methods/to_pdf.rb +12 -0
  95. data/lib/pdf_paradise/utility_scripts/README.md +3 -0
  96. data/lib/pdf_paradise/utility_scripts/automatic_pdf_title.rb +104 -0
  97. data/lib/pdf_paradise/utility_scripts/check_syntax_of_pdf_files.rb +106 -0
  98. data/lib/pdf_paradise/utility_scripts/combine_these_pdf_pages.rb +118 -0
  99. data/lib/pdf_paradise/utility_scripts/convert_pdf_to_text.rb +179 -0
  100. data/lib/pdf_paradise/utility_scripts/delete_last_page_of_this_pdf_file.rb +180 -0
  101. data/lib/pdf_paradise/utility_scripts/delete_the_first_page_of_this_pdf_file/delete_the_first_page_of_this_pdf_file.rb +429 -0
  102. data/lib/pdf_paradise/utility_scripts/delete_this_page_of_this_pdf_file.rb +356 -0
  103. data/lib/pdf_paradise/utility_scripts/djvu_to_pdf.rb +87 -0
  104. data/lib/pdf_paradise/utility_scripts/extract_all_images_from_this_pdf_file.rb +129 -0
  105. data/lib/pdf_paradise/utility_scripts/extract_pdf_page.rb +283 -0
  106. data/lib/pdf_paradise/utility_scripts/pdf_file_n_total_pages.rb +348 -0
  107. data/lib/pdf_paradise/utility_scripts/pdf_optimizer.rb +111 -0
  108. data/lib/pdf_paradise/utility_scripts/pdf_statistics.rb +148 -0
  109. data/lib/pdf_paradise/utility_scripts/pdf_to_html.rb +75 -0
  110. data/lib/pdf_paradise/utility_scripts/remove_images.rb +110 -0
  111. data/lib/pdf_paradise/utility_scripts/rotate_pdf_file.rb +303 -0
  112. data/lib/pdf_paradise/utility_scripts/split_pdf.rb +364 -0
  113. data/lib/pdf_paradise/utility_scripts/to_pdf.rb +130 -0
  114. data/lib/pdf_paradise/utility_scripts/to_qdf.rb +66 -0
  115. data/lib/pdf_paradise/version/version.rb +19 -0
  116. data/lib/pdf_paradise/www/README.md +2 -0
  117. data/lib/pdf_paradise/www/sinatra/app.rb +304 -0
  118. data/lib/pdf_paradise/yaml/working_on_these_pdf_files.yml +4 -0
  119. data/lib/pdf_paradise.rb +5 -0
  120. data/pdf_paradise.gemspec +61 -0
  121. data/test/fpdf/001_minimal_example.rb +12 -0
  122. data/test/fpdf/002.pdf +0 -0
  123. data/test/fpdf/002_header_and_footer_example.rb +64 -0
  124. data/test/fpdf/003.pdf +98 -0
  125. data/test/fpdf/003_justified_paragraphs.rb +96 -0
  126. data/test/fpdf/file1.md +3 -0
  127. data/test/fpdf/file2.md +3 -0
  128. data/test/fpdf/test.pdf +0 -0
  129. data/test/testing_pdf_paradise.rb +12 -0
  130. metadata +239 -0
@@ -0,0 +1,173 @@
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 --mega-checker
26
+ #
27
+ # Invocation examples:
28
+ #
29
+ # pdf_paradise --mega-checker
30
+ # pdf_paradise --super-check
31
+ # pdf_paradise --check-every-pdf-file
32
+ #
33
+ # ===================================================================== #
34
+ when /^-?-?mega(-|_)?checker$/i,
35
+ /^-?-?super(-|_)?check$/i,
36
+ /^-?-?check(-|_)?every(-|_)?pdf(-|_)?file$/i
37
+ mega_check_every_pdf_file_in_the_current_directory
38
+ # ===================================================================== #
39
+ # === pdfpa --jruby
40
+ #
41
+ # Invocation example:
42
+ #
43
+ # jruby /usr/bin/pdf_paradise --jruby1
44
+ #
45
+ # ===================================================================== #
46
+ when /^-?-?jruby1?$/
47
+ require 'pdf_paradise/gui/jruby/delete_the_first_or_the_last_page_of_this_pdf_file/delete_the_first_or_the_last_page_of_this_pdf_file.rb'
48
+ start_the_jruby_interface_for_deleting_pages_in_a_pdf_file
49
+ # ===================================================================== #
50
+ # === pdfpa --libui1
51
+ # ===================================================================== #
52
+ when /^-?-?libui1$/
53
+ require 'pdf_paradise/gui/libui/remove_the_first_page_of_this_pdf_file/remove_the_first_page_of_this_pdf_file.rb'
54
+ PdfParadise::GUI::LibUI::RemoveTheFirstPageOfThisPdfFile.new
55
+ # ===================================================================== #
56
+ # === pdfpa --libui
57
+ #
58
+ # This entry point will always refer to the most important
59
+ # libui widget.
60
+ # ===================================================================== #
61
+ when /^-?-?libui$/
62
+ start_the_most_important_libui_wrapper(commandline_arguments?)
63
+ # ===================================================================== #
64
+ # === pdfpa --open-pdf-files
65
+ # ===================================================================== #
66
+ when /^-?-?open(-|_)?pdf(-|_)?files$/
67
+ open_the_default_pdf_files
68
+ # ===================================================================== #
69
+ # === pdfparadise --controller
70
+ # ===================================================================== #
71
+ when /^-?-?controller$/
72
+ require 'pdf_paradise/gui/gtk3/controller/controller.rb'
73
+ PdfParadise::GUI::Gtk::Controller.run
74
+ # ===================================================================== #
75
+ # === --use-this-pdf-file=DONE_Life_History_Evolution_WS_17_4.pdf
76
+ # ===================================================================== #
77
+ when /^-?-?use(-|_)?this(-|_)?pdf(-|_)?file=(.+)$/, # === $4
78
+ /^-?-?set(-|_)?pdf(-|_)?title=(.+)$/, # === $3
79
+ /^-?-?use(-|_)?this(-|_)?title=(.+)$/ # === $4
80
+ i = $3 # <- This is for the second line ^^^.
81
+ i = $4 if $4 # <- And this is for the first line.
82
+ set_use_this_pdf_file(i)
83
+ # ===================================================================== #
84
+ # === pdf_paradise --sinatra
85
+ # ===================================================================== #
86
+ when /^-?-?sinatra$/i,
87
+ /^-?-?www$/i # === pdf_paradise --www
88
+ require 'pdf_paradise/www/sinatra/app.rb'
89
+ PdfParadise.start_sinatra_interface
90
+ # ===================================================================== #
91
+ # === pdf_paradise --autoconvert
92
+ # ===================================================================== #
93
+ when /^-?-?autoconvert$/i
94
+ autoconvert_pdf_files_in_the_main_directory
95
+ # ===================================================================== #
96
+ # === pdf_paradise --gui
97
+ # === pdf_paradise --gtk
98
+ # ===================================================================== #
99
+ when /^-?-?gui$/,
100
+ /^-?-?gtk$/
101
+ require 'pdf_paradise/gui/gtk2/split_pdf_file/split_pdf_file.rb'
102
+ PdfParadise.start_gtk_gui
103
+ # ===================================================================== #
104
+ # === pdf_paradise --show_last_opened_pdf_files
105
+ # ===================================================================== #
106
+ when /^-?-?show(-|_)?last(-|_)?opened(-|_)?pdf(-|_)?files$/i,
107
+ /^-?-?pdf(-|_)?file(-|_)?content$/i, # pdfparadise --pdf-file-content
108
+ /^-?-?last(-|_)?open(-|_)?pdf\??$/i,
109
+ /^-?-?last-pdf$/i,
110
+ /^-?-?last\??$/i,
111
+ /^-?-?pdf\??$/i # pdfparadise --pdf?
112
+ PdfParadise.show_last_opened_pdf_files
113
+ # ===================================================================== #
114
+ # === pdfparadise --store-open-pdf-files
115
+ # ===================================================================== #
116
+ when /^-?-?store(-|_| )?open(-|_| )?pdf(-|_| )?files$/,
117
+ /^-?-?store(-|_| )?open(-|_| )?pdfs?$/,
118
+ /^-?-?store(-|_| )?pdf(-|_| )?files$/,
119
+ /^-?-?store(-|_| )?pdfs$/
120
+ PdfParadise.store_all_currently_open_pdf_files
121
+ # ===================================================================== #
122
+ # === pdf_paradise --array-all-currently-opened-pdf-files
123
+ # ===================================================================== #
124
+ when /^-?-?array(-|_| )?all(-|_| )?currently(-|_| )?opened(-|_| )?pdf(-|_| )?files$/i,
125
+ /^-?-?show(-|_| )?currently(-|_| )?open(-|_| )?pdf(-|_| )?files$/i
126
+ PdfParadise.return_array_of_all_currently_opened_pdf_files(:do_not_run_locate).each {|entry|
127
+ e entry
128
+ }
129
+ # ===================================================================== #
130
+ # === pdfparadise --open-last-pdf-files
131
+ # ===================================================================== #
132
+ when /^-?-?open(-|_| )?last(-|_| )?pdf(-|_| )?files$/,
133
+ /^-?-?open(-|_| )?last(-|_| )?opened(-|_| )?pdf(-|_| )?files$/,
134
+ /^-?-?open(-|_| )?last(-|_| )?pdfs$/,
135
+ /^-?-?main$/, # <- This is the main task (main tag)
136
+ /^-?-?restore$/
137
+ PdfParadise.open_last_opened_pdf_files
138
+ # ===================================================================== #
139
+ # === pdf_paradise --shrink-pdf-size-of=foobar.pdf
140
+ # ===================================================================== #
141
+ when /^-?-?shrink(-|_)?pdf(-|_)?size(-|_)?of=(.+)/i,
142
+ /^-?-?shrink=(.+)/i
143
+ this_file = $1.to_s.dup
144
+ this_file = $4.to_s.dup if $4
145
+ reduce_size_of_this_pdf_file(this_file)
146
+ # ===================================================================== #
147
+ # === pdf_paradise --help
148
+ # ===================================================================== #
149
+ when /^-?-?help/
150
+ show_help
151
+ # ===================================================================== #
152
+ # === --set_title="Hello world!"
153
+ # ===================================================================== #
154
+ when /^--set(-|_)?title=(.+)$/,
155
+ /^--title=(.+)$/
156
+ # =================================================================== #
157
+ # @use_this_pdf_file has to have been set properly before calling
158
+ # this method.
159
+ # =================================================================== #
160
+ i = $1
161
+ i = $2 if $2
162
+ PdfParadise.set_title_of_this_pdf_file(@use_this_pdf_file, i)
163
+ else
164
+ e "Unknown command: #{i}" unless File.exist?(i)
165
+ end
166
+ end
167
+ end
168
+
169
+ end
170
+
171
+ if __FILE__ == $PROGRAM_NAME
172
+ PdfParadise.menu(ARGV)
173
+ end
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === PdfParadise::CompressThisPdfFile
6
+ #
7
+ # This class can be used to compress a .pdf file.
8
+ #
9
+ # Usage example:
10
+ #
11
+ # PdfParadise::CompressThisPdfFile.new(ARGV)
12
+ #
13
+ # =========================================================================== #
14
+ require 'pdf_paradise/base/base.rb'
15
+
16
+ module PdfParadise
17
+
18
+ class CompressThisPdfFile < ::PdfParadise::Base # === PdfParadise::CompressThisPdfFile
19
+
20
+ include FileUtils::Verbose
21
+
22
+ # ========================================================================= #
23
+ # === initialize
24
+ # ========================================================================= #
25
+ def initialize(
26
+ i = ARGV,
27
+ run_already = true
28
+ )
29
+ reset
30
+ set_commandline_arguments(i)
31
+ run if run_already
32
+ end
33
+
34
+ # ========================================================================= #
35
+ # === reset (reset tag)
36
+ # ========================================================================= #
37
+ def reset
38
+ super()
39
+ infer_the_namespace
40
+ # ======================================================================= #
41
+ # === @use_this_compatibility_level
42
+ #
43
+ # Note that -dCompatibilityLevel will be overridden by what is
44
+ # chosen in -dPDFSETTINGS.
45
+ #
46
+ # Note that this refers to the PDF standard; 1.7 is fairly recent.
47
+ # ======================================================================= #
48
+ @use_this_compatibility_level = '1.7'
49
+ # ======================================================================= #
50
+ # === @d_pdf_settings_value
51
+ # ======================================================================= #
52
+ @d_pdf_settings_value = :screen # Or :prepress
53
+ end
54
+
55
+ # ========================================================================= #
56
+ # === set_work_on_these_files
57
+ # ========================================================================= #
58
+ def set_work_on_these_files(i)
59
+ @work_on_these_files = [i].flatten.compact
60
+ end
61
+
62
+ # ========================================================================= #
63
+ # === do_work_on_all_files
64
+ # ========================================================================= #
65
+ def do_work_on_all_files(
66
+ i = @work_on_these_files
67
+ )
68
+ i.each {|this_file|
69
+ store_into_this_file = 'compressed_PDF_file.pdf'
70
+ cmd = "gs -sDEVICE=pdfwrite "\
71
+ "-dCompatibilityLevel=#{@use_this_compatibility_level} "\
72
+ "-dPDFSETTINGS=/#{@d_pdf_settings_value} "\
73
+ "-dNOPAUSE -dQUIET -dBATCH "\
74
+ "-sOutputFile=#{store_into_this_file} #{this_file}"
75
+ e
76
+ e "#{rev}The compressed .pdf file will be stored "\
77
+ "here: #{sfile(store_into_this_file)}"
78
+ e
79
+ esystem cmd
80
+ e
81
+ }
82
+ end
83
+
84
+ # ========================================================================= #
85
+ # === run (run tag)
86
+ #
87
+ # Note that using /ebook rather than /prepress would reduce the file
88
+ # size even further.
89
+ # ========================================================================= #
90
+ def run
91
+ set_work_on_these_files(commandline_arguments?)
92
+ do_work_on_all_files
93
+ end
94
+
95
+ end
96
+
97
+ # =========================================================================== #
98
+ # === PdfParadise.compress_this_pdf_file
99
+ # =========================================================================== #
100
+ def self.compress_this_pdf_file(i = ARGV)
101
+ PdfParadise::CompressThisPdfFile.new(i)
102
+ end
103
+
104
+ end
105
+
106
+ if __FILE__ == $PROGRAM_NAME
107
+ PdfParadise::CompressThisPdfFile.new(ARGV)
108
+ end # compressthispdffile
@@ -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; self.instance_eval { alias compress_via_hexapdf compress_via_pdf } # === PdfParadise.compress_via_hexapdf
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
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'pdf_paradise/compress/compress_via_qpdf.rb'
6
+ # PdfParadise.compress_via_qpdf(ARGV)
7
+ # =========================================================================== #
8
+ module PdfParadise
9
+
10
+ require 'pdf_paradise/toplevel_methods/esystem.rb'
11
+
12
+ # ========================================================================= #
13
+ # === PdfParadise.compress_via_qpdf
14
+ # ========================================================================= #
15
+ def self.compress_via_qpdf(
16
+ this_file = 'foobar.pdf'
17
+ )
18
+ if this_file.is_a? Array
19
+ this_file = this_file.first
20
+ end
21
+ e
22
+ esystem 'qpdf --compress-streams=y --object-streams=generate '\
23
+ '--recompress-flate --optimize-images --compression-level=9 '+
24
+ this_file+' compressed_output_'+File.basename(this_file)
25
+ e
26
+ end
27
+
28
+ end
29
+
30
+ if __FILE__ == $PROGRAM_NAME
31
+ PdfParadise.compress_via_qpdf(ARGV)
32
+ end # compress_via_qpdf
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'pdf_paradise/constants/constants.rb'
6
+ # =========================================================================== #
7
+ module PdfParadise
8
+
9
+ # ========================================================================= #
10
+ # === HOME_DIRECTORY_OF_USER_X
11
+ # ========================================================================= #
12
+ if ENV['USERS']
13
+ HOME_DIRECTORY_OF_USER_X = ENV['USERS'].to_s+'/x/'
14
+ else
15
+ HOME_DIRECTORY_OF_USER_X = '/home/x/'
16
+ end
17
+
18
+ # ========================================================================= #
19
+ # === MAIN_PDF_YAML_FILE
20
+ # ========================================================================= #
21
+ MAIN_PDF_YAML_FILE =
22
+ "#{HOME_DIRECTORY_OF_USER_X}programming/ruby/src/roebe/lib/roebe/yaml/"\
23
+ "main_pdf.yml"
24
+
25
+ # ========================================================================= #
26
+ # === FILE_ALL_CURRENTLY_OPENED_PDF_FILES
27
+ # ========================================================================= #
28
+ FILE_ALL_CURRENTLY_OPENED_PDF_FILES =
29
+ '/home/Temp/all_currently_opened_pdf_files.md'
30
+
31
+ # ========================================================================= #
32
+ # === AUTOCONVERT_PDF_FILES_RESIDING_IN_THIS_DIRECTORY
33
+ # ========================================================================= #
34
+ AUTOCONVERT_PDF_FILES_RESIDING_IN_THIS_DIRECTORY = '/ingrid/pdf/'
35
+
36
+ # ========================================================================= #
37
+ # === PdfParadise.main_directory?
38
+ # ========================================================================= #
39
+ def self.main_directory?
40
+ AUTOCONVERT_PDF_FILES_RESIDING_IN_THIS_DIRECTORY
41
+ end
42
+
43
+ # ========================================================================= #
44
+ # === PdfParadise.file_main_pdf_yaml_file?
45
+ #
46
+ # This method will return a String such as
47
+ # '/home/x/programming/ruby/src/roebe/lib/roebe/yaml/main_pdf.yml'.
48
+ # ========================================================================= #
49
+ def self.file_main_pdf_yaml_file?
50
+ MAIN_PDF_YAML_FILE
51
+ end; self.instance_eval { alias file_pdf_viewer? file_main_pdf_yaml_file? } # === PdfParadise.file_pdf_viewer?
52
+
53
+ # ========================================================================= #
54
+ # === PdfParadise.file_working_on_these_pdf_files
55
+ #
56
+ # This method will return a String such as
57
+ # '/usr/lib/ruby/site_ruby/3.1.0/pdf_paradise/yaml/working_on_these_pdf_files.yml'.
58
+ # ========================================================================= #
59
+ def self.file_working_on_these_pdf_files
60
+ unless ::PdfParadise.respond_to?(:project_base_directory?)
61
+ require 'pdf_paradise/project/project.rb'
62
+ end
63
+ project_base_directory?+
64
+ 'yaml/working_on_these_pdf_files.yml'
65
+ end
66
+
67
+ # ========================================================================= #
68
+ # === PdfParadise.pdf_viewer?
69
+ #
70
+ # Use the default and registered .pdf viewer.
71
+ # ========================================================================= #
72
+ def self.pdf_viewer?(i = file_main_pdf_yaml_file?)
73
+ YAML.load_file(i)
74
+ end
75
+
76
+ end
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === PdfParadise::ConvertTextToPdf
6
+ #
7
+ # Use this class to convert a text file to a .pdf file.
8
+ #
9
+ # Usage examples:
10
+ # PdfParadise::ConvertTextToPdf.new
11
+ # ============================================================================ #
12
+ require 'pdf_paradise/requires/colours.rb'
13
+
14
+ module PdfParadise
15
+
16
+ class ConvertTextToPdf # require 'convert_text_to_pdf'; ConvertTextToPdf.new
17
+
18
+ include Colours
19
+
20
+ # ========================================================================= #
21
+ # === FONT_FAMILY
22
+ # ========================================================================= #
23
+ FONT_FAMILY = 'Courier'
24
+
25
+ # ========================================================================= #
26
+ # === initialize
27
+ # ========================================================================= #
28
+ def initialize(
29
+ i = nil,
30
+ run_already = true
31
+ )
32
+ set_input(i)
33
+ reset
34
+ run if run_already
35
+ end
36
+
37
+ # ========================================================================= #
38
+ # === reset
39
+ # ========================================================================= #
40
+ def reset # reset tag
41
+ @font_family = FONT_FAMILY
42
+ end
43
+
44
+ # ========================================================================= #
45
+ # === set_input
46
+ # ========================================================================= #
47
+ def set_input(i = '')
48
+ i = i.first if i.is_a? Array
49
+ i = i.to_s.dup
50
+ @input = i
51
+ end
52
+
53
+ # ========================================================================= #
54
+ # === convert_this_text_file
55
+ #
56
+ # Use enscript to created a .ps file, and then ps2pdf
57
+ # (or ps2pdfwr) to convert to .pdf
58
+ #
59
+ # The following script creates a .pdf file with 10 pt
60
+ # left and right margins, and uses a courier font that
61
+ # is 7.3 pts wide and 10 pts high, so a 132 col printout
62
+ # fits on an 8 1/2 X 11 page. Use enscript to setup your
63
+ # page, fonts, etc.
64
+ # ========================================================================= #
65
+ def convert_this_text_file(i = @input)
66
+ if File.exist? i
67
+ _ 'enscript -B --margins=10:10: -o outputfile.ps -f '+
68
+ @font_family+'@7.3/10 '+i
69
+ _ 'ps2pdfwr outputfile.ps x.pdf'
70
+ else
71
+ e 'Sorry, there is no file at '+i+'.'
72
+ end
73
+ end
74
+
75
+ # ========================================================================= #
76
+ # === _
77
+ # ========================================================================= #
78
+ def _(i)
79
+ e i
80
+ system i
81
+ end
82
+
83
+ # ========================================================================= #
84
+ # === run
85
+ # ========================================================================= #
86
+ def run # (run tag)
87
+ convert_this_text_file
88
+ end
89
+
90
+ end; end
91
+
92
+ if __FILE__ == $PROGRAM_NAME
93
+ PdfParadise::ConvertTextToPdf.new(ARGV)
94
+ end # text_to_pdf
@@ -0,0 +1,17 @@
1
+ button {
2
+ border: 2px solid black;
3
+ }
4
+
5
+ .BG_yellow {
6
+ background-color: yellow;
7
+ }
8
+
9
+ .BG_floralwhite {
10
+ background-color: floralwhite;
11
+ }
12
+
13
+ scrolledwindow {
14
+ border: 1px solid black;
15
+ padding: 4px;
16
+ margin: 4px;
17
+ }
@@ -0,0 +1,2 @@
1
+ This is a fork of fpdf. The code may not work, though - I mostly added it
2
+ to have this work a bit like an archive.
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # Translation of the bookmark class from the PHP FPDF script from Olivier
6
+ # Plathey.
7
+ #
8
+ # Translated by Sylvain Lafleur and ?? with the help of Brian Ollenberger
9
+ #
10
+ # First added in 1.53b
11
+ #
12
+ # Usage is as follows:
13
+ #
14
+ # require 'fpdf'
15
+ # require 'bookmark'
16
+ # pdf = FPDF.new
17
+ # pdf.extend(PDF_Bookmark)
18
+ #
19
+ # This allows it to be combined with other extensions, such as the Chinese
20
+ # module.
21
+ # =========================================================================== #
22
+ module PDF_Bookmark
23
+
24
+ # ========================================================================= #
25
+ # === PDF_Bookmark.extend_object
26
+ # ========================================================================= #
27
+ def self.extend_object(i)
28
+ i.instance_eval('@outlines,@OutlineRoot=[],0')
29
+ super(i)
30
+ end
31
+
32
+ # ========================================================================= #
33
+ # === bookmark
34
+ # ========================================================================= #
35
+ def bookmark(txt, level = 0, y = 0)
36
+ y = self.GetY if y == -1
37
+ @outlines.push(
38
+ {
39
+ 't' => txt,
40
+ 'l' => level,
41
+ 'y' => y,
42
+ 'p' => self.PageNo
43
+ }
44
+ )
45
+ end; alias Bookmark bookmark # === Bookmark
46
+
47
+ # ========================================================================= #
48
+ # === putbookmarks
49
+ # ========================================================================= #
50
+ def putbookmarks
51
+ @nb = @outlines.size
52
+ return if @nb == 0
53
+ lru=[]
54
+ level=0
55
+ @outlines.each_index { |i|
56
+ o = @outlines[i]
57
+ if o['l']>0
58
+ parent=lru[o['l']-1]
59
+ # Set parent and last pointers
60
+ @outlines[i]['parent']=parent
61
+ @outlines[parent]['last']=i
62
+ if o['l']>level
63
+ # Level increasing: set first pointer
64
+ @outlines[parent]['first']=i
65
+ end
66
+ else
67
+ @outlines[i]['parent']=@nb
68
+ end
69
+ if o['l']<=level and i>0
70
+ # Set prev and next pointers
71
+ prev=lru[o['l']]
72
+ @outlines[prev]['next']=i
73
+ @outlines[i]['prev']=prev
74
+ end
75
+ lru[o['l']]=i
76
+ level = o['l']
77
+ }
78
+ # Outline items
79
+ n=@n+1
80
+ @outlines.each_index do |i|
81
+ o=@outlines[i]
82
+ newobj
83
+ out('<</Title '+(textstring(o['t'])))
84
+ out('/Parent '+(n+o['parent']).to_s+' 0 R')
85
+ if o['prev']
86
+ out('/Prev '+(n+o['prev']).to_s+' 0 R')
87
+ end
88
+ if o['next']
89
+ out('/Next '+(n+o['next']).to_s+' 0 R')
90
+ end
91
+ if o['first']
92
+ out('/First '+(n+o['first']).to_s+' 0 R')
93
+ end
94
+ if o['last']
95
+ out('/Last '+(n+o['last']).to_s+' 0 R')
96
+ end
97
+ out(sprintf('/Dest [%d 0 R /XYZ 0 %.2f
98
+ null]',1+2*o['p'],(@h-o['y'])*@k))
99
+ out('/Count 0>>')
100
+ out('endobj')
101
+ end
102
+ # Outline root
103
+ newobj
104
+ @OutlineRoot=@n
105
+ out('<</Type /Outlines /First '+n.to_s+' 0 R')
106
+ out('/Last '+(n+lru[0]).to_s+' 0 R>>')
107
+ out('endobj')
108
+ end
109
+
110
+ # ========================================================================= #
111
+ # === putresources
112
+ # ========================================================================= #
113
+ def putresources
114
+ super
115
+ putbookmarks
116
+ end
117
+
118
+ # ========================================================================= #
119
+ # === putcatalog
120
+ # ========================================================================= #
121
+ def putcatalog
122
+ super
123
+ if not @outlines.empty?
124
+ out('/Outlines '+@OutlineRoot.to_s+' 0 R')
125
+ out('/PageMode /UseOutlines')
126
+ end
127
+ end
128
+
129
+ end