lib/libis/format/converter/pdf_converter.rb in libis-format-1.1.0 vs lib/libis/format/converter/pdf_converter.rb in libis-format-1.2.0

- old
+ new

@@ -3,10 +3,11 @@ require_relative 'base' require 'libis/tools/extend/hash' require 'libis/format/tool/pdf_copy' require 'libis/format/tool/pdf_to_pdfa' +require 'libis/format/tool/pdfa_validator' require 'libis/format/tool/pdf_optimizer' module Libis module Format module Converter @@ -118,11 +119,11 @@ if format == :PDFA and source result = pdf_to_pdfa(source, target) end { - files: [result] + files: [result], converter: self.class.name } end @@ -161,14 +162,19 @@ def pdf_to_pdfa(source, target) using_temp(target) do |tmpname| result = Libis::Format::Tool::PdfToPdfa.run source, tmpname - if result[:status] != 0 - error("Pdf/A conversion encountered errors:\n%s", result[:err].join("\n")) + + if result[:command][:status] != 0 + error("Pdf/A conversion encountered errors:\n%s", (result[:command][:out] + result[:command][:err]).join("\n")) next nil else - warn("Pdf/A conversion warnings:\n%s", result[:err].join("\n")) unless result[:err].empty? + r = Libis::Format::Tool::PdfaValidator.run tmpname + if r[:status] != 0 + error "Pdf/A file failed to validate with following errors:\n%s", (r[:err] || r[:out] || []).join("\n") + next nil + end end tmpname end end