Sha256: 60b1554b8100811b2b633c63e1b82217240e6825edb2789d50db1d1beef397d4

Contents?: true

Size: 740 Bytes

Versions: 2

Compression:

Stored size: 740 Bytes

Contents

require "open3"
require "mn2pdf/version"

module Mn2pdf
  MN2PDF_JAR_PATH = File.join(File.dirname(__FILE__), "../bin/mn2pdf.jar")

  def self.help
    cmd = ["java", "-jar", MN2PDF_JAR_PATH].join(" ")
    message, error_str, status = Open3.capture3(cmd)

    message
  end

  def self.convert(url_path, output_path, xsl_stylesheet)
    return if url_path.nil? || output_path.nil? || xsl_stylesheet.nil?

    puts MN2PDF_JAR_PATH
    cmd = ["java", "-Xss5m", "-Xmx1024m", "-jar", MN2PDF_JAR_PATH, "--xml-file",
           url_path, "--xsl-file", xsl_stylesheet, "--pdf-file",
           output_path].join(" ")

    puts cmd
    _, error_str, status = Open3.capture3(cmd)

    unless status.success?
      raise error_str
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mn2pdf-1.13 lib/mn2pdf.rb
mn2pdf-1.11 lib/mn2pdf.rb