Sha256: 246a39ed2557973c230d5a1752cc13858ce06fcb00b219a9b1d6eecc8b11b9fe

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

require "isodoc"
require_relative "metadata"
require "fileutils"
require_relative "base_convert"

module IsoDoc
  module NIST
    # A {Converter} implementation that generates PDF HTML output, and a
    # document schema encapsulation of the document for validation
    class PdfConvert < IsoDoc::PdfConvert
      def initialize(options)
        @libdir = File.dirname(__FILE__)
        super
      end

      def convert(filename, file = nil, debug = false)
        file = File.read(filename, encoding: "utf-8") if file.nil?
        docxml, outname_html, dir = convert_init(file, filename, debug)
        @series =  docxml&.at(ns("//bibdata/series/abbreviation"))&.text
        /\.xml$/.match(filename) or
          filename = Tempfile.open([outname_html, ".xml"], encoding: "utf-8") do |f|
          f.write file
          f.path
        end
        FileUtils.rm_rf dir
        ::Metanorma::Output::XslfoPdf.new.convert(
          filename, outname_html + ".pdf",
          File.join(@libdir, @series == "NIST CSWP" ?
                    "nist.cswp.xsl" : "nist.sp.xsl"))
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
metanorma-nist-1.0.10 lib/isodoc/nist/pdf_convert.rb
metanorma-nist-1.0.9 lib/isodoc/nist/pdf_convert.rb
metanorma-nist-1.0.8 lib/isodoc/nist/pdf_convert.rb
metanorma-nist-1.0.7 lib/isodoc/nist/pdf_convert.rb
metanorma-nist-1.0.6 lib/isodoc/nist/pdf_convert.rb