libis-format 1.0.4 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (232) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +5 -1
  3. data/.travis.yml +43 -25
  4. data/README.md +2 -2
  5. data/base/Dockerfile +35 -0
  6. data/base/Dockerfile.alpine +20 -0
  7. data/base/Dockerfile.rvm +56 -0
  8. data/base/rework_path +20 -0
  9. data/docker_cfg.yml +1 -0
  10. data/lib/libis/format.rb +12 -3
  11. data/lib/libis/format/cli/convert.rb +4 -4
  12. data/lib/libis/format/config.rb +15 -10
  13. data/lib/libis/format/converter/audio_converter.rb +3 -37
  14. data/lib/libis/format/converter/base.rb +22 -8
  15. data/lib/libis/format/converter/chain.rb +3 -3
  16. data/lib/libis/format/converter/image_assembler.rb +82 -0
  17. data/lib/libis/format/converter/image_converter.rb +20 -138
  18. data/lib/libis/format/converter/image_splitter.rb +84 -0
  19. data/lib/libis/format/converter/image_watermarker.rb +261 -0
  20. data/lib/libis/format/converter/jp2_converter.rb +2 -2
  21. data/lib/libis/format/converter/office_converter.rb +2 -2
  22. data/lib/libis/format/converter/pdf_assembler.rb +66 -0
  23. data/lib/libis/format/converter/pdf_converter.rb +10 -134
  24. data/lib/libis/format/converter/pdf_metadata.rb +82 -0
  25. data/lib/libis/format/converter/pdf_optimizer.rb +67 -0
  26. data/lib/libis/format/converter/pdf_protecter.rb +147 -0
  27. data/lib/libis/format/converter/pdf_selecter.rb +83 -0
  28. data/lib/libis/format/converter/pdf_splitter.rb +70 -0
  29. data/lib/libis/format/converter/pdf_watermarker_header.rb +71 -0
  30. data/lib/libis/format/converter/pdf_watermarker_image.rb +76 -0
  31. data/lib/libis/format/converter/pdf_watermarker_text.rb +93 -0
  32. data/lib/libis/format/converter/spreadsheet_converter.rb +2 -2
  33. data/lib/libis/format/converter/video_converter.rb +1 -1
  34. data/lib/libis/format/identifier.rb +3 -3
  35. data/lib/libis/format/info.rb +27 -0
  36. data/lib/libis/format/library.rb +147 -0
  37. data/lib/libis/format/tool.rb +4 -1
  38. data/lib/libis/format/tool/droid.rb +2 -2
  39. data/lib/libis/format/tool/extension_identification.rb +4 -4
  40. data/lib/libis/format/tool/ffmpeg.rb +1 -1
  41. data/lib/libis/format/tool/fido.rb +1 -1
  42. data/lib/libis/format/tool/fop_pdf.rb +1 -1
  43. data/lib/libis/format/tool/identification_tool.rb +6 -6
  44. data/lib/libis/format/tool/office_to_pdf.rb +1 -1
  45. data/lib/libis/format/tool/pdf_merge.rb +4 -4
  46. data/lib/libis/format/tool/{pdf_copy.rb → pdf_metadata.rb} +6 -6
  47. data/lib/libis/format/tool/pdf_protect.rb +47 -0
  48. data/lib/libis/format/tool/pdf_select.rb +47 -0
  49. data/lib/libis/format/tool/pdf_split.rb +5 -5
  50. data/lib/libis/format/tool/pdf_to_pdfa.rb +1 -2
  51. data/lib/libis/format/tool/pdf_watermark.rb +47 -0
  52. data/lib/libis/format/tool/pdfa_validator.rb +3 -4
  53. data/lib/libis/format/tool/spreadsheet_to_ods.rb +2 -1
  54. data/lib/libis/format/version.rb +1 -1
  55. data/lib/libis/format/yaml_loader.rb +71 -0
  56. data/libis-format.gemspec +5 -4
  57. data/tools/PdfTool.jar +0 -0
  58. data/tools/bcpkix-jdk15on-167.jar +0 -0
  59. data/tools/bcprov-jdk15on-167.jar +0 -0
  60. data/tools/fop/build/fop.jar +0 -0
  61. data/tools/fop/conf/fop.xconf +466 -0
  62. data/tools/fop/fop +258 -0
  63. data/tools/fop/fop.bat +75 -0
  64. data/tools/fop/fop.cmd +31 -0
  65. data/tools/fop/fop.js +341 -0
  66. data/tools/fop/lib/README.txt +243 -0
  67. data/tools/fop/lib/avalon-framework-api-4.3.1.jar +0 -0
  68. data/tools/fop/lib/avalon-framework-impl-4.3.1.jar +0 -0
  69. data/tools/fop/lib/avalon-framework.LICENSE.txt +175 -0
  70. data/tools/fop/lib/avalon-framework.NOTICE.TXT +11 -0
  71. data/tools/fop/lib/batik-all-1.10.jar +0 -0
  72. data/tools/fop/lib/batik.LICENSE.txt +201 -0
  73. data/tools/fop/lib/batik.NOTICE.txt +18 -0
  74. data/tools/fop/lib/commons-io-1.3.1.jar +0 -0
  75. data/tools/fop/lib/commons-io.LICENSE.txt +203 -0
  76. data/tools/fop/lib/commons-io.NOTICE.txt +6 -0
  77. data/tools/fop/lib/commons-logging-1.0.4.jar +0 -0
  78. data/tools/fop/lib/commons-logging.LICENSE.txt +202 -0
  79. data/tools/fop/lib/commons-logging.NOTICE.txt +3 -0
  80. data/tools/fop/lib/fontbox-2.0.7.jar +0 -0
  81. data/tools/fop/lib/serializer-2.7.2.jar +0 -0
  82. data/tools/fop/lib/serializer.LICENSE.txt +201 -0
  83. data/tools/fop/lib/serializer.NOTICE.txt +15 -0
  84. data/tools/fop/lib/xalan-2.7.2.jar +0 -0
  85. data/tools/fop/lib/xalan.BCEL.LICENSE.txt +52 -0
  86. data/tools/fop/lib/xalan.LICENSE.txt +202 -0
  87. data/tools/fop/lib/xalan.NOTICE.txt +44 -0
  88. data/tools/fop/lib/xalan.regexp.LICENSE.txt +52 -0
  89. data/tools/fop/lib/xalan.runtime.LICENSE.txt +20 -0
  90. data/tools/fop/lib/xerces.LICENSE.txt +56 -0
  91. data/tools/fop/lib/xercesImpl-2.9.1.jar +0 -0
  92. data/tools/fop/lib/xercesImpl.LICENSE.txt +201 -0
  93. data/tools/fop/lib/xercesImpl.NOTICE.txt +14 -0
  94. data/tools/fop/lib/xml-apis-1.3.04.jar +0 -0
  95. data/tools/fop/lib/xml-apis-ext-1.3.04.jar +0 -0
  96. data/tools/fop/lib/xml-apis-ext.LICENSE.dom-documentation.txt +73 -0
  97. data/tools/fop/lib/xml-apis-ext.LICENSE.dom-software.txt +61 -0
  98. data/tools/fop/lib/xml-apis-ext.LICENSE.sac.html +75 -0
  99. data/tools/fop/lib/xml-apis-ext.LICENSE.txt +202 -0
  100. data/tools/fop/lib/xml-apis-ext.NOTICE.txt +16 -0
  101. data/tools/fop/lib/xml-apis-ext.README.dom.txt +56 -0
  102. data/tools/fop/lib/xml-apis.LICENSE-SAX.html +17 -0
  103. data/tools/fop/lib/xml-apis.LICENSE.DOM-documentation.html +74 -0
  104. data/tools/fop/lib/xml-apis.LICENSE.DOM-software.html +66 -0
  105. data/tools/fop/lib/xml-apis.LICENSE.txt +201 -0
  106. data/tools/fop/lib/xml-apis.NOTICE.txt +13 -0
  107. data/tools/fop/lib/xmlgraphics-commons-2.3.jar +0 -0
  108. data/tools/fop/lib/xmlgraphics-commons.LICENSE.txt +202 -0
  109. data/tools/fop/lib/xmlgraphics-commons.NOTICE.txt +5 -0
  110. data/tools/pdfbox/pdfbox-app-2.0.13.jar +0 -0
  111. data/tools/pdfbox/{pdfbox-app-1.8.10.jar → preflight-app-2.0.13.jar} +0 -0
  112. metadata +86 -246
  113. data/lib/libis/format/type_database.rb +0 -134
  114. data/lib/libis/format/type_database_impl.rb +0 -120
  115. data/spec/converter_audio_spec.rb +0 -66
  116. data/spec/converter_fop_spec.rb +0 -37
  117. data/spec/converter_image_spec.rb +0 -166
  118. data/spec/converter_office_spec.rb +0 -84
  119. data/spec/converter_pdf_spec.rb +0 -30
  120. data/spec/converter_repository_spec.rb +0 -97
  121. data/spec/converter_spreadsheet_spec.rb +0 -39
  122. data/spec/converter_video_spec.rb +0 -97
  123. data/spec/converter_xsl_spec.rb +0 -56
  124. data/spec/data/Cevennes2.bmp +0 -0
  125. data/spec/data/Cevennes2.jp2 +0 -0
  126. data/spec/data/Cevennes2.ppm +0 -22492
  127. data/spec/data/NikonRaw-CameraRaw.TIF +0 -0
  128. data/spec/data/NikonRaw-CaptureOne.tif +0 -0
  129. data/spec/data/audio/carlin_disappointed.aac +0 -0
  130. data/spec/data/audio/carlin_disappointed.ac3 +0 -0
  131. data/spec/data/audio/carlin_disappointed.aiff +0 -0
  132. data/spec/data/audio/carlin_disappointed.au +0 -0
  133. data/spec/data/audio/carlin_disappointed.flac +0 -0
  134. data/spec/data/audio/carlin_disappointed.m4a +0 -0
  135. data/spec/data/audio/carlin_disappointed.mka +0 -0
  136. data/spec/data/audio/carlin_disappointed.mp3 +0 -0
  137. data/spec/data/audio/carlin_disappointed.ogg +0 -0
  138. data/spec/data/audio/carlin_disappointed.ra +0 -0
  139. data/spec/data/audio/carlin_disappointed.voc +0 -0
  140. data/spec/data/audio/carlin_disappointed.wav +0 -0
  141. data/spec/data/audio/carlin_disappointed.wma +0 -0
  142. data/spec/data/audio/greensleeves.aac +0 -0
  143. data/spec/data/audio/greensleeves.ac3 +0 -0
  144. data/spec/data/audio/greensleeves.aiff +0 -0
  145. data/spec/data/audio/greensleeves.au +0 -0
  146. data/spec/data/audio/greensleeves.flac +0 -0
  147. data/spec/data/audio/greensleeves.m4a +0 -0
  148. data/spec/data/audio/greensleeves.mka +0 -0
  149. data/spec/data/audio/greensleeves.mp3 +0 -0
  150. data/spec/data/audio/greensleeves.ogg +0 -0
  151. data/spec/data/audio/greensleeves.ra +0 -0
  152. data/spec/data/audio/greensleeves.voc +0 -0
  153. data/spec/data/audio/greensleeves.wav +0 -0
  154. data/spec/data/audio/greensleeves.wma +0 -0
  155. data/spec/data/audio/king_nonviolence.aac +0 -0
  156. data/spec/data/audio/king_nonviolence.ac3 +0 -0
  157. data/spec/data/audio/king_nonviolence.aiff +0 -0
  158. data/spec/data/audio/king_nonviolence.au +0 -0
  159. data/spec/data/audio/king_nonviolence.flac +0 -0
  160. data/spec/data/audio/king_nonviolence.m4a +0 -0
  161. data/spec/data/audio/king_nonviolence.mka +0 -0
  162. data/spec/data/audio/king_nonviolence.mp3 +0 -0
  163. data/spec/data/audio/king_nonviolence.ogg +0 -0
  164. data/spec/data/audio/king_nonviolence.ra +0 -0
  165. data/spec/data/audio/king_nonviolence.voc +0 -0
  166. data/spec/data/audio/king_nonviolence.wav +0 -0
  167. data/spec/data/audio/king_nonviolence.wma +0 -0
  168. data/spec/data/audio/top_gun_secret.aac +0 -0
  169. data/spec/data/audio/top_gun_secret.ac3 +0 -0
  170. data/spec/data/audio/top_gun_secret.aiff +0 -0
  171. data/spec/data/audio/top_gun_secret.au +0 -0
  172. data/spec/data/audio/top_gun_secret.flac +0 -0
  173. data/spec/data/audio/top_gun_secret.m4a +0 -0
  174. data/spec/data/audio/top_gun_secret.mka +0 -0
  175. data/spec/data/audio/top_gun_secret.mp3 +0 -0
  176. data/spec/data/audio/top_gun_secret.ogg +0 -0
  177. data/spec/data/audio/top_gun_secret.ra +0 -0
  178. data/spec/data/audio/top_gun_secret.voc +0 -0
  179. data/spec/data/audio/top_gun_secret.wav +0 -0
  180. data/spec/data/audio/top_gun_secret.wma +0 -0
  181. data/spec/data/multipage.tif +0 -0
  182. data/spec/data/multipage.tif.jp2 +0 -0
  183. data/spec/data/test-ead.xml +0 -392
  184. data/spec/data/test-jpg.tif +0 -0
  185. data/spec/data/test-lzw.tif +0 -0
  186. data/spec/data/test-options.jpg +0 -0
  187. data/spec/data/test-options.png +0 -0
  188. data/spec/data/test.bmp +0 -0
  189. data/spec/data/test.doc +0 -0
  190. data/spec/data/test.docx +0 -0
  191. data/spec/data/test.gif +0 -0
  192. data/spec/data/test.jpg +0 -0
  193. data/spec/data/test.ods +0 -0
  194. data/spec/data/test.odt +0 -0
  195. data/spec/data/test.pdf +0 -0
  196. data/spec/data/test.pdf.tif +0 -0
  197. data/spec/data/test.png +0 -0
  198. data/spec/data/test.ps +0 -8631
  199. data/spec/data/test.psd +0 -0
  200. data/spec/data/test.rtf +0 -1455
  201. data/spec/data/test.tif +0 -0
  202. data/spec/data/test.txt +0 -12
  203. data/spec/data/test.xcf +0 -0
  204. data/spec/data/test.xls +0 -0
  205. data/spec/data/test.xlsx +0 -0
  206. data/spec/data/test.xml +0 -4
  207. data/spec/data/test_pdfa.pdf +0 -0
  208. data/spec/data/video/SampleVideo_1080x720_2mb.flv +0 -0
  209. data/spec/data/video/SampleVideo_1080x720_2mb.mkv +0 -0
  210. data/spec/data/video/SampleVideo_1080x720_2mb.mp4 +0 -0
  211. data/spec/data/video/SampleVideo_176x144_2mb.3gp +0 -0
  212. data/spec/data/video/SampleVideo_320x240_2mb.3gp +0 -0
  213. data/spec/data/video/SampleVideo_360x240_2mb.flv +0 -0
  214. data/spec/data/video/SampleVideo_360x240_2mb.mkv +0 -0
  215. data/spec/data/video/SampleVideo_360x240_2mb.mp4 +0 -0
  216. data/spec/data/video/copyright.png +0 -0
  217. data/spec/data/xml/134476_ead.XML +0 -1
  218. data/spec/data/xml/134476_ead.pdf +0 -0
  219. data/spec/data/xml/134476_fo.XML +0 -383
  220. data/spec/data/xml/134476_raw.XML +0 -141
  221. data/spec/data/xml/ead2fo_pdf.xsl +0 -1453
  222. data/spec/data/xml/header_nolink_pdf.xsl +0 -120
  223. data/spec/data/xml/lookupLists.xsl +0 -488
  224. data/spec/data/xml/scope_eadToHTML.xsl +0 -2376
  225. data/spec/data/xml/scope_xmlToEAD_dom.xsl +0 -952
  226. data/spec/identifier_spec.rb +0 -161
  227. data/spec/spec_helper.rb +0 -58
  228. data/spec/test_types.yml +0 -12
  229. data/spec/type_database_spec.rb +0 -140
  230. data/tools/bcpkix-jdk15on-1.49.jar +0 -0
  231. data/tools/bcprov-jdk15on-1.49.jar +0 -0
  232. data/tools/pdfbox/preflight-app-1.8.10.jar +0 -0
@@ -0,0 +1,83 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative 'base'
4
+
5
+ require 'libis/format/tool/pdf_select'
6
+
7
+ module Libis
8
+ module Format
9
+ module Converter
10
+
11
+ # noinspection DuplicatedCode
12
+ class PdfSelecter < Libis::Format::Converter::Base
13
+
14
+ def self.input_types
15
+ [:PDF]
16
+ end
17
+
18
+ def self.output_types(format = nil)
19
+ return [] unless input_types.include?(format) if format
20
+ [:PDF]
21
+ end
22
+
23
+ def pdf_select(_)
24
+ #force usage of this converter
25
+ end
26
+
27
+ def initialize
28
+ super
29
+ @options[:ranges] = []
30
+ end
31
+
32
+ # Select a partial list of pages
33
+ # @param [String] selection as described in com.itextpdf.text.pdf.SequenceList: [!][o][odd][e][even]start-end
34
+ def range(selection)
35
+ @options[:ranges] += selection.split(/\s*,\s*/) unless selection.blank?
36
+ end
37
+
38
+ # Select a partial list of pages
39
+ # @param [String|Array<String>] selection as described in com.itextpdf.text.pdf.SequenceList: [!][o][odd][e][even]start-end
40
+ def ranges(selection)
41
+ case selection
42
+ when Array
43
+ @options[:ranges] += selection unless selection.empty?
44
+ when String
45
+ range(selection)
46
+ else
47
+ # nothing
48
+ end
49
+ end
50
+
51
+ def convert(source, target, format, opts = {})
52
+ super
53
+
54
+ result = nil
55
+
56
+ unless @options.empty?
57
+ result = convert_pdf(source, target)
58
+ return nil unless result
59
+ end
60
+
61
+ result
62
+
63
+ end
64
+
65
+ def convert_pdf(source, target)
66
+
67
+ using_temp(target) do |tmpname|
68
+ opts = @options[:ranges].map { |range| ["-r", range] }.compact.flatten
69
+ result = Libis::Format::Tool::PdfSelect.run(source, tmpname, opts)
70
+ unless result[:err].empty?
71
+ error("Pdf selection encountered errors:\n%s", result[:err].join(join("\n")))
72
+ next nil
73
+ end
74
+ tmpname
75
+ end
76
+
77
+ end
78
+
79
+ end
80
+
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,70 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative 'base'
4
+
5
+ require 'libis/format/tool/pdf_split'
6
+
7
+ module Libis
8
+ module Format
9
+ module Converter
10
+
11
+ # noinspection DuplicatedCode
12
+ class PdfSplitter < Libis::Format::Converter::Base
13
+
14
+ def self.input_types
15
+ [:PDF]
16
+ end
17
+
18
+ def self.output_types(format = nil)
19
+ return [] unless input_types.include?(format) if format
20
+ [:PDFA]
21
+ end
22
+
23
+ def self.category
24
+ :splitter
25
+ end
26
+
27
+ def initialize
28
+ super
29
+ end
30
+
31
+ # Split at given page. If omitted, nil or 0, the source PDF will be split at every page
32
+ def page(v)
33
+ @options[:page] = v unless v.blank?
34
+ end
35
+
36
+ def convert(source, target, format, opts = {})
37
+ super
38
+
39
+ result = split(source, target)
40
+ return nil unless result
41
+
42
+ result
43
+ end
44
+
45
+ private
46
+
47
+ def split(source, target)
48
+
49
+ result = Libis::Format::Tool::PdfSplit.run(
50
+ source, target,
51
+ @options.map { |k, v|
52
+ if v.nil?
53
+ nil
54
+ else
55
+ ["--#{k}", v]
56
+ end }.compact.flatten
57
+ )
58
+ unless result[:err].empty?
59
+ error("Pdf split encountered errors:\n%s", result[:err].join(join("\n")))
60
+ return nil
61
+ end
62
+ result[:out]
63
+
64
+ end
65
+
66
+ end
67
+
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,71 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative 'base'
4
+
5
+ require 'libis/format/tool/pdf_watermark'
6
+
7
+ module Libis
8
+ module Format
9
+ module Converter
10
+
11
+ class PdfWatermarkerHeader < Libis::Format::Converter::Base
12
+
13
+ def self.input_types
14
+ [:PDF]
15
+ end
16
+
17
+ def self.output_types(format = nil)
18
+ return [] unless input_types.include?(format) if format
19
+ [:PDF]
20
+ end
21
+
22
+ def pdf_watermark_header(_)
23
+ #force usage of this converter
24
+ end
25
+
26
+ def initialize
27
+ super
28
+ end
29
+
30
+ def text(v)
31
+ @options[:text] = v.blank? ? nil : v
32
+ end
33
+
34
+ def convert(source, target, format, opts = {})
35
+ super
36
+
37
+ result = convert_pdf(source, target)
38
+ return nil unless result
39
+
40
+ result
41
+
42
+ end
43
+
44
+ # noinspection DuplicatedCode
45
+ def convert_pdf(source, target)
46
+
47
+ using_temp(target) do |tmpname|
48
+ result = Libis::Format::Tool::PdfWatermark.run(
49
+ source, tmpname, 'header',
50
+ @options.map {|k, v|
51
+ if v.nil?
52
+ nil
53
+ else
54
+ ["--#{k}", v]
55
+ end
56
+ }.compact.flatten
57
+ )
58
+ unless result[:err].empty?
59
+ error("Pdf conversion encountered errors:\n%s", result[:err].join(join("\n")))
60
+ next nil
61
+ end
62
+ tmpname
63
+ end
64
+
65
+ end
66
+
67
+ end
68
+
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,76 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative 'base'
4
+
5
+ require 'libis/format/tool/pdf_watermark'
6
+
7
+ module Libis
8
+ module Format
9
+ module Converter
10
+
11
+ class PdfWatermarkerImage < Libis::Format::Converter::Base
12
+
13
+ def self.input_types
14
+ [:PDF]
15
+ end
16
+
17
+ def self.output_types(format = nil)
18
+ return [] unless input_types.include?(format) if format
19
+ [:PDF]
20
+ end
21
+
22
+ def pdf_watermark_image(_)
23
+ #force usage of this converter
24
+ end
25
+
26
+ def initialize
27
+ super
28
+ @options[:opacity] = '0.3'
29
+ end
30
+
31
+ def file(v)
32
+ @file = v
33
+ end
34
+
35
+ def opacity(v)
36
+ @options[:opacity] = v unless v.blank?
37
+ end
38
+
39
+ def convert(source, target, format, opts = {})
40
+ super
41
+
42
+ result = convert_pdf(source, target)
43
+ return nil unless result
44
+
45
+ result
46
+
47
+ end
48
+
49
+ # noinspection DuplicatedCode
50
+ def convert_pdf(source, target)
51
+
52
+ using_temp(target) do |tmpname|
53
+ result = Libis::Format::Tool::PdfWatermark.run(
54
+ source, tmpname, 'image',
55
+ @options.map {|k, v|
56
+ if v.nil?
57
+ nil
58
+ else
59
+ ["--#{k}", v]
60
+ end
61
+ }.compact.flatten + [@file]
62
+ )
63
+ unless result[:err].empty?
64
+ error("Pdf conversion encountered errors:\n%s", result[:err].join(join("\n")))
65
+ next nil
66
+ end
67
+ tmpname
68
+ end
69
+
70
+ end
71
+
72
+ end
73
+
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,93 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative 'base'
4
+
5
+ require 'libis/format/tool/pdf_watermark'
6
+
7
+ module Libis
8
+ module Format
9
+ module Converter
10
+
11
+ class PdfWatermarkerText < Libis::Format::Converter::Base
12
+
13
+ def self.input_types
14
+ [:PDF]
15
+ end
16
+
17
+ def self.output_types(format = nil)
18
+ return [] unless input_types.include?(format) if format
19
+ [:PDF]
20
+ end
21
+
22
+ def pdf_watermark_text(_)
23
+ #force usage of this converter
24
+ end
25
+
26
+ def initialize
27
+ super
28
+ @text = []
29
+ @options[:opacity] = '0.3'
30
+ end
31
+
32
+ def text(v)
33
+ @text += v.split("\n")
34
+ end
35
+
36
+ def rotation(v)
37
+ @options[:rotation] = v unless v.blank?
38
+ end
39
+
40
+ def size(v)
41
+ @options[:size] = v unless v.blank?
42
+ end
43
+
44
+ def opacity(v)
45
+ @options[:opacity] = v unless v.blank?
46
+ end
47
+
48
+ def gap(v)
49
+ @options[:gap] = v
50
+ end
51
+
52
+ def padding(v)
53
+ @options[:padding] = v
54
+ end
55
+
56
+ def convert(source, target, format, opts = {})
57
+ super
58
+
59
+ result = convert_pdf(source, target)
60
+ return nil unless result
61
+
62
+ result
63
+
64
+ end
65
+
66
+ # noinspection DuplicatedCode
67
+ def convert_pdf(source, target)
68
+
69
+ using_temp(target) do |tmpname|
70
+ result = Libis::Format::Tool::PdfWatermark.run(
71
+ source, tmpname, 'text',
72
+ @options.map {|k, v|
73
+ if v.nil?
74
+ nil
75
+ else
76
+ ["--#{k}", v]
77
+ end
78
+ }.compact.flatten + @text
79
+ )
80
+ unless result[:err].empty?
81
+ error("Pdf conversion encountered errors:\n%s", result[:err].join(join("\n")))
82
+ next nil
83
+ end
84
+ tmpname
85
+ end
86
+
87
+ end
88
+
89
+ end
90
+
91
+ end
92
+ end
93
+ end
@@ -3,7 +3,7 @@
3
3
  require_relative 'base'
4
4
 
5
5
  require 'libis/format/tool/spreadsheet_to_ods'
6
- require 'libis/format/type_database'
6
+ require 'libis/format/library'
7
7
 
8
8
  module Libis
9
9
  module Format
@@ -20,7 +20,7 @@ module Libis
20
20
  end
21
21
 
22
22
  def self.output_types(format = nil)
23
- return [] unless input_types.include?(format)
23
+ return [] unless input_types.include?(format) if format
24
24
  [:OO_CALC]
25
25
  end
26
26
 
@@ -14,7 +14,7 @@ module Libis
14
14
  end
15
15
 
16
16
  def self.output_types(format = nil)
17
- return [] unless input_types.include?(format)
17
+ return [] unless input_types.include?(format) if format
18
18
  [:GIF, :WEBM, :MP4, :MPG, :MKV, :MJP2, :QTFF, :AVI, :OGGV, :WMV, :DV, :FLV, :SWF]
19
19
  end
20
20
 
@@ -9,7 +9,7 @@ require 'libis/tools/extend/string'
9
9
  require 'libis/tools/extend/empty'
10
10
  require 'nori/core_ext/object'
11
11
 
12
- require 'libis/format/type_database'
12
+ require 'libis/format/library'
13
13
 
14
14
  require_relative 'config'
15
15
  require_relative 'tool/fido'
@@ -132,7 +132,7 @@ module Libis
132
132
  if doc.validates_against?(xsd_file)
133
133
  log_msg result, :debug, "XML file validated against XML Schema: #{xsd_file}"
134
134
  info = {mimetype: mime, tool_raw: file_result[:tool], tool: :xsd_validation, match_type: 'xsd_validation', format_version: '', }
135
- file_result.merge! Libis::Format::TypeDatabase.enrich(info, PUID: :puid, MIME: :mimetype, NAME: :format_name)
135
+ file_result.merge! Libis::Format::Library.enrich(info, puid: :puid, mimetype: :mimetype, name: :format_name)
136
136
  end
137
137
  rescue => e
138
138
  # Do nothing - probably Nokogiri chrashed during validation. Could have many causes
@@ -208,7 +208,7 @@ module Libis
208
208
  end
209
209
 
210
210
  def get_mimetype(puid)
211
- ::Libis::Format::TypeDatabase.puid_typeinfo(puid)[:MIME].first rescue nil
211
+ ::Libis::Format::Library.get_field_by(:puid, puid, :mimetypes)
212
212
  end
213
213
 
214
214
  def get_best_result(results)