#!/usr/bin/env ruby =begin = Info Enforces a document to be rendered as PDF/A. This will disable multimedia features and JavaScript execution in Adobe Reader. = License Copyright (C) 2016 Guillaume Delugré. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Origami. If not, see . =end begin require 'origami' rescue LoadError $: << File.join(__dir__, '../lib') require 'origami' end include Origami require 'optparse' class OptParser BANNER = <] [-o ] Enforces a document to be rendered as PDF/A. This will disable multimedia features and JavaScript execution in Adobe Reader. Bug reports or feature requests at: http://github.com/gdelugre/origami Options: USAGE def self.parser(options) OptionParser.new do |opts| opts.banner = BANNER opts.on("-o", "--output FILE", "Output PDF file (stdout by default)") do |o| options[:output] = o end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end end def self.parse(args) options = { output: STDOUT, } self.parser(options).parse!(args) options end end begin @options = OptParser.parse(ARGV) target = (ARGV.empty?) ? STDIN : ARGV.shift params = { verbosity: Parser::VERBOSE_QUIET, } PDF.read(target, params).save(@options[:output], intent: 'PDF/A', noindent: true) rescue abort "#{$!.class}: #{$!.message}" end