libis-format 1.0.2 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) 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/bin/libis_format +8 -0
  10. data/docker_cfg.yml +1 -0
  11. data/lib/libis/format.rb +12 -2
  12. data/lib/libis/format/cli/convert.rb +310 -0
  13. data/lib/libis/format/cli/format.rb +77 -0
  14. data/lib/libis/format/cli/prompt_helper.rb +87 -0
  15. data/lib/libis/format/cli/sub_command.rb +22 -0
  16. data/lib/libis/format/command_line.rb +25 -0
  17. data/lib/libis/format/config.rb +15 -10
  18. data/lib/libis/format/converter/audio_converter.rb +3 -37
  19. data/lib/libis/format/converter/base.rb +22 -8
  20. data/lib/libis/format/converter/chain.rb +3 -3
  21. data/lib/libis/format/converter/image_assembler.rb +82 -0
  22. data/lib/libis/format/converter/image_converter.rb +32 -127
  23. data/lib/libis/format/converter/image_splitter.rb +84 -0
  24. data/lib/libis/format/converter/image_watermarker.rb +261 -0
  25. data/lib/libis/format/converter/jp2_converter.rb +2 -2
  26. data/lib/libis/format/converter/office_converter.rb +2 -2
  27. data/lib/libis/format/converter/pdf_assembler.rb +66 -0
  28. data/lib/libis/format/converter/pdf_converter.rb +10 -134
  29. data/lib/libis/format/converter/pdf_metadata.rb +82 -0
  30. data/lib/libis/format/converter/pdf_optimizer.rb +67 -0
  31. data/lib/libis/format/converter/pdf_protecter.rb +147 -0
  32. data/lib/libis/format/converter/pdf_selecter.rb +77 -0
  33. data/lib/libis/format/converter/pdf_splitter.rb +70 -0
  34. data/lib/libis/format/converter/pdf_watermarker_header.rb +71 -0
  35. data/lib/libis/format/converter/pdf_watermarker_image.rb +76 -0
  36. data/lib/libis/format/converter/pdf_watermarker_text.rb +93 -0
  37. data/lib/libis/format/converter/spreadsheet_converter.rb +2 -2
  38. data/lib/libis/format/converter/video_converter.rb +1 -1
  39. data/lib/libis/format/identifier.rb +7 -7
  40. data/lib/libis/format/info.rb +27 -0
  41. data/lib/libis/format/library.rb +147 -0
  42. data/lib/libis/format/tool.rb +4 -1
  43. data/lib/libis/format/tool/droid.rb +2 -2
  44. data/lib/libis/format/tool/extension_identification.rb +4 -4
  45. data/lib/libis/format/tool/ffmpeg.rb +1 -1
  46. data/lib/libis/format/tool/fido.rb +1 -1
  47. data/lib/libis/format/tool/fop_pdf.rb +1 -1
  48. data/lib/libis/format/tool/identification_tool.rb +6 -6
  49. data/lib/libis/format/tool/office_to_pdf.rb +1 -1
  50. data/lib/libis/format/tool/pdf_merge.rb +4 -4
  51. data/lib/libis/format/tool/{pdf_copy.rb → pdf_metadata.rb} +6 -6
  52. data/lib/libis/format/tool/pdf_protect.rb +47 -0
  53. data/lib/libis/format/tool/pdf_select.rb +47 -0
  54. data/lib/libis/format/tool/pdf_split.rb +5 -5
  55. data/lib/libis/format/tool/pdf_to_pdfa.rb +1 -2
  56. data/lib/libis/format/tool/pdf_watermark.rb +47 -0
  57. data/lib/libis/format/tool/pdfa_validator.rb +3 -4
  58. data/lib/libis/format/tool/spreadsheet_to_ods.rb +2 -1
  59. data/lib/libis/format/version.rb +1 -1
  60. data/lib/libis/format/yaml_loader.rb +71 -0
  61. data/libis-format.gemspec +5 -5
  62. data/tools/PdfTool.jar +0 -0
  63. data/tools/bcpkix-jdk15on-167.jar +0 -0
  64. data/tools/bcprov-jdk15on-167.jar +0 -0
  65. data/tools/fop/build/fop.jar +0 -0
  66. data/tools/fop/conf/fop.xconf +466 -0
  67. data/tools/fop/fop +258 -0
  68. data/tools/fop/fop.bat +75 -0
  69. data/tools/fop/fop.cmd +31 -0
  70. data/tools/fop/fop.js +341 -0
  71. data/tools/fop/lib/README.txt +243 -0
  72. data/tools/fop/lib/avalon-framework-api-4.3.1.jar +0 -0
  73. data/tools/fop/lib/avalon-framework-impl-4.3.1.jar +0 -0
  74. data/tools/fop/lib/avalon-framework.LICENSE.txt +175 -0
  75. data/tools/fop/lib/avalon-framework.NOTICE.TXT +11 -0
  76. data/tools/fop/lib/batik-all-1.10.jar +0 -0
  77. data/tools/fop/lib/batik.LICENSE.txt +201 -0
  78. data/tools/fop/lib/batik.NOTICE.txt +18 -0
  79. data/tools/fop/lib/commons-io-1.3.1.jar +0 -0
  80. data/tools/fop/lib/commons-io.LICENSE.txt +203 -0
  81. data/tools/fop/lib/commons-io.NOTICE.txt +6 -0
  82. data/tools/fop/lib/commons-logging-1.0.4.jar +0 -0
  83. data/tools/fop/lib/commons-logging.LICENSE.txt +202 -0
  84. data/tools/fop/lib/commons-logging.NOTICE.txt +3 -0
  85. data/tools/fop/lib/fontbox-2.0.7.jar +0 -0
  86. data/tools/fop/lib/serializer-2.7.2.jar +0 -0
  87. data/tools/fop/lib/serializer.LICENSE.txt +201 -0
  88. data/tools/fop/lib/serializer.NOTICE.txt +15 -0
  89. data/tools/fop/lib/xalan-2.7.2.jar +0 -0
  90. data/tools/fop/lib/xalan.BCEL.LICENSE.txt +52 -0
  91. data/tools/fop/lib/xalan.LICENSE.txt +202 -0
  92. data/tools/fop/lib/xalan.NOTICE.txt +44 -0
  93. data/tools/fop/lib/xalan.regexp.LICENSE.txt +52 -0
  94. data/tools/fop/lib/xalan.runtime.LICENSE.txt +20 -0
  95. data/tools/fop/lib/xerces.LICENSE.txt +56 -0
  96. data/tools/fop/lib/xercesImpl-2.9.1.jar +0 -0
  97. data/tools/fop/lib/xercesImpl.LICENSE.txt +201 -0
  98. data/tools/fop/lib/xercesImpl.NOTICE.txt +14 -0
  99. data/tools/fop/lib/xml-apis-1.3.04.jar +0 -0
  100. data/tools/fop/lib/xml-apis-ext-1.3.04.jar +0 -0
  101. data/tools/fop/lib/xml-apis-ext.LICENSE.dom-documentation.txt +73 -0
  102. data/tools/fop/lib/xml-apis-ext.LICENSE.dom-software.txt +61 -0
  103. data/tools/fop/lib/xml-apis-ext.LICENSE.sac.html +75 -0
  104. data/tools/fop/lib/xml-apis-ext.LICENSE.txt +202 -0
  105. data/tools/fop/lib/xml-apis-ext.NOTICE.txt +16 -0
  106. data/tools/fop/lib/xml-apis-ext.README.dom.txt +56 -0
  107. data/tools/fop/lib/xml-apis.LICENSE-SAX.html +17 -0
  108. data/tools/fop/lib/xml-apis.LICENSE.DOM-documentation.html +74 -0
  109. data/tools/fop/lib/xml-apis.LICENSE.DOM-software.html +66 -0
  110. data/tools/fop/lib/xml-apis.LICENSE.txt +201 -0
  111. data/tools/fop/lib/xml-apis.NOTICE.txt +13 -0
  112. data/tools/fop/lib/xmlgraphics-commons-2.3.jar +0 -0
  113. data/tools/fop/lib/xmlgraphics-commons.LICENSE.txt +202 -0
  114. data/tools/fop/lib/xmlgraphics-commons.NOTICE.txt +5 -0
  115. data/tools/pdfbox/pdfbox-app-2.0.13.jar +0 -0
  116. data/tools/pdfbox/{pdfbox-app-1.8.10.jar → preflight-app-2.0.13.jar} +0 -0
  117. metadata +93 -259
  118. data/lib/libis/format/type_database.rb +0 -201
  119. data/spec/converter_audio_spec.rb +0 -66
  120. data/spec/converter_fop_spec.rb +0 -37
  121. data/spec/converter_image_spec.rb +0 -166
  122. data/spec/converter_office_spec.rb +0 -84
  123. data/spec/converter_pdf_spec.rb +0 -30
  124. data/spec/converter_repository_spec.rb +0 -97
  125. data/spec/converter_spreadsheet_spec.rb +0 -39
  126. data/spec/converter_video_spec.rb +0 -97
  127. data/spec/converter_xsl_spec.rb +0 -56
  128. data/spec/data/Cevennes2.bmp +0 -0
  129. data/spec/data/Cevennes2.jp2 +0 -0
  130. data/spec/data/Cevennes2.ppm +0 -22492
  131. data/spec/data/NikonRaw-CameraRaw.TIF +0 -0
  132. data/spec/data/NikonRaw-CaptureOne.tif +0 -0
  133. data/spec/data/audio/carlin_disappointed.aac +0 -0
  134. data/spec/data/audio/carlin_disappointed.ac3 +0 -0
  135. data/spec/data/audio/carlin_disappointed.aiff +0 -0
  136. data/spec/data/audio/carlin_disappointed.au +0 -0
  137. data/spec/data/audio/carlin_disappointed.flac +0 -0
  138. data/spec/data/audio/carlin_disappointed.m4a +0 -0
  139. data/spec/data/audio/carlin_disappointed.mka +0 -0
  140. data/spec/data/audio/carlin_disappointed.mp3 +0 -0
  141. data/spec/data/audio/carlin_disappointed.ogg +0 -0
  142. data/spec/data/audio/carlin_disappointed.ra +0 -0
  143. data/spec/data/audio/carlin_disappointed.voc +0 -0
  144. data/spec/data/audio/carlin_disappointed.wav +0 -0
  145. data/spec/data/audio/carlin_disappointed.wma +0 -0
  146. data/spec/data/audio/greensleeves.aac +0 -0
  147. data/spec/data/audio/greensleeves.ac3 +0 -0
  148. data/spec/data/audio/greensleeves.aiff +0 -0
  149. data/spec/data/audio/greensleeves.au +0 -0
  150. data/spec/data/audio/greensleeves.flac +0 -0
  151. data/spec/data/audio/greensleeves.m4a +0 -0
  152. data/spec/data/audio/greensleeves.mka +0 -0
  153. data/spec/data/audio/greensleeves.mp3 +0 -0
  154. data/spec/data/audio/greensleeves.ogg +0 -0
  155. data/spec/data/audio/greensleeves.ra +0 -0
  156. data/spec/data/audio/greensleeves.voc +0 -0
  157. data/spec/data/audio/greensleeves.wav +0 -0
  158. data/spec/data/audio/greensleeves.wma +0 -0
  159. data/spec/data/audio/king_nonviolence.aac +0 -0
  160. data/spec/data/audio/king_nonviolence.ac3 +0 -0
  161. data/spec/data/audio/king_nonviolence.aiff +0 -0
  162. data/spec/data/audio/king_nonviolence.au +0 -0
  163. data/spec/data/audio/king_nonviolence.flac +0 -0
  164. data/spec/data/audio/king_nonviolence.m4a +0 -0
  165. data/spec/data/audio/king_nonviolence.mka +0 -0
  166. data/spec/data/audio/king_nonviolence.mp3 +0 -0
  167. data/spec/data/audio/king_nonviolence.ogg +0 -0
  168. data/spec/data/audio/king_nonviolence.ra +0 -0
  169. data/spec/data/audio/king_nonviolence.voc +0 -0
  170. data/spec/data/audio/king_nonviolence.wav +0 -0
  171. data/spec/data/audio/king_nonviolence.wma +0 -0
  172. data/spec/data/audio/top_gun_secret.aac +0 -0
  173. data/spec/data/audio/top_gun_secret.ac3 +0 -0
  174. data/spec/data/audio/top_gun_secret.aiff +0 -0
  175. data/spec/data/audio/top_gun_secret.au +0 -0
  176. data/spec/data/audio/top_gun_secret.flac +0 -0
  177. data/spec/data/audio/top_gun_secret.m4a +0 -0
  178. data/spec/data/audio/top_gun_secret.mka +0 -0
  179. data/spec/data/audio/top_gun_secret.mp3 +0 -0
  180. data/spec/data/audio/top_gun_secret.ogg +0 -0
  181. data/spec/data/audio/top_gun_secret.ra +0 -0
  182. data/spec/data/audio/top_gun_secret.voc +0 -0
  183. data/spec/data/audio/top_gun_secret.wav +0 -0
  184. data/spec/data/audio/top_gun_secret.wma +0 -0
  185. data/spec/data/multipage.tif +0 -0
  186. data/spec/data/multipage.tif.jp2 +0 -0
  187. data/spec/data/test-ead.xml +0 -392
  188. data/spec/data/test-jpg.tif +0 -0
  189. data/spec/data/test-lzw.tif +0 -0
  190. data/spec/data/test-options.jpg +0 -0
  191. data/spec/data/test-options.png +0 -0
  192. data/spec/data/test.bmp +0 -0
  193. data/spec/data/test.doc +0 -0
  194. data/spec/data/test.docx +0 -0
  195. data/spec/data/test.gif +0 -0
  196. data/spec/data/test.jpg +0 -0
  197. data/spec/data/test.ods +0 -0
  198. data/spec/data/test.odt +0 -0
  199. data/spec/data/test.pdf +0 -0
  200. data/spec/data/test.pdf.tif +0 -0
  201. data/spec/data/test.png +0 -0
  202. data/spec/data/test.ps +0 -8631
  203. data/spec/data/test.psd +0 -0
  204. data/spec/data/test.rtf +0 -1455
  205. data/spec/data/test.tif +0 -0
  206. data/spec/data/test.txt +0 -12
  207. data/spec/data/test.xcf +0 -0
  208. data/spec/data/test.xls +0 -0
  209. data/spec/data/test.xlsx +0 -0
  210. data/spec/data/test.xml +0 -4
  211. data/spec/data/test_pdfa.pdf +0 -0
  212. data/spec/data/video/SampleVideo_1080x720_2mb.flv +0 -0
  213. data/spec/data/video/SampleVideo_1080x720_2mb.mkv +0 -0
  214. data/spec/data/video/SampleVideo_1080x720_2mb.mp4 +0 -0
  215. data/spec/data/video/SampleVideo_176x144_2mb.3gp +0 -0
  216. data/spec/data/video/SampleVideo_320x240_2mb.3gp +0 -0
  217. data/spec/data/video/SampleVideo_360x240_2mb.flv +0 -0
  218. data/spec/data/video/SampleVideo_360x240_2mb.mkv +0 -0
  219. data/spec/data/video/SampleVideo_360x240_2mb.mp4 +0 -0
  220. data/spec/data/video/copyright.png +0 -0
  221. data/spec/data/xml/134476_ead.XML +0 -1
  222. data/spec/data/xml/134476_ead.pdf +0 -0
  223. data/spec/data/xml/134476_fo.XML +0 -383
  224. data/spec/data/xml/134476_raw.XML +0 -141
  225. data/spec/data/xml/ead2fo_pdf.xsl +0 -1453
  226. data/spec/data/xml/header_nolink_pdf.xsl +0 -120
  227. data/spec/data/xml/lookupLists.xsl +0 -488
  228. data/spec/data/xml/scope_eadToHTML.xsl +0 -2376
  229. data/spec/data/xml/scope_xmlToEAD_dom.xsl +0 -952
  230. data/spec/identifier_spec.rb +0 -161
  231. data/spec/spec_helper.rb +0 -58
  232. data/spec/test_types.yml +0 -12
  233. data/spec/type_database_spec.rb +0 -140
  234. data/tools/bcpkix-jdk15on-1.49.jar +0 -0
  235. data/tools/bcprov-jdk15on-1.49.jar +0 -0
  236. data/tools/pdfbox/preflight-app-1.8.10.jar +0 -0
@@ -0,0 +1,77 @@
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[:range] = []
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[:range] << selection unless selection.blank?
36
+ end
37
+
38
+ def convert(source, target, format, opts = {})
39
+ super
40
+
41
+ result = nil
42
+
43
+ unless @options.empty?
44
+ result = convert_pdf(source, target)
45
+ return nil unless result
46
+ end
47
+
48
+ result
49
+
50
+ end
51
+
52
+ def convert_pdf(source, target)
53
+
54
+ using_temp(target) do |tmpname|
55
+ result = Libis::Format::Tool::PdfSelect.run(
56
+ source, tmpname,
57
+ @options.map { |k, v|
58
+ if v.nil?
59
+ nil
60
+ else
61
+ ["--#{k}", v]
62
+ end }.compact.flatten
63
+ )
64
+ unless result[:err].empty?
65
+ error("Pdf selection encountered errors:\n%s", result[:err].join(join("\n")))
66
+ next nil
67
+ end
68
+ tmpname
69
+ end
70
+
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+ end
77
+ 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'
@@ -42,10 +42,10 @@ module Libis
42
42
 
43
43
  def get(file, options = {})
44
44
 
45
- options[:droid] = true unless options.keys.include?(:droid) and options[:tool] and options[:tool] != :droid
46
- options[:fido] = true unless options.keys.include?(:fido) and options[:tool] and options[:tool] != :fido
47
- options[:file] = true unless options.keys.include?(:file) and options[:tool] and options[:tool] != :file
48
- options[:xml_validation] = true unless options.keys.include?(:xml_validation) and !options[:xml_validation]
45
+ options[:droid] = true unless options.keys.include?(:droid) or (options[:tool] and options[:tool] != :droid)
46
+ options[:fido] = true unless options.keys.include?(:fido) or (options[:tool] and options[:tool] != :fido)
47
+ options[:file] = true unless options.keys.include?(:file) or (options[:tool] and options[:tool] != :file)
48
+ options[:xml_validation] = true if options[:xml_validation].nil?
49
49
 
50
50
  result = {messages: [], output: {}, formats: {}}
51
51
 
@@ -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)