Sha256: 3bfb9e1b3d5d2ffd134956d40b37fe421f29d93fa797ee8d43e7730e9f9dbeea

Contents?: true

Size: 1.25 KB

Versions: 19

Compression:

Stored size: 1.25 KB

Contents

require "metanorma"

module IsoDoc
  class XslfoPdfConvert < ::IsoDoc::Convert

    def initialize(options)
      super
      @maxwidth = 500
      @maxheight = 800
    end

    def tmpimagedir_suffix
      "_pdfimages"
    end

    def initialize(options)
      @format = :pdf
      @suffix = "pdf"
      super
    end

    def pdf_stylesheet(docxml)
      nil
    end

    def convert(input_filename, file = nil, debug = false, output_filename = nil)
      file = File.read(input_filename, encoding: "utf-8") if file.nil?
      docxml, filename, dir = convert_init(file, input_filename, debug)
      /\.xml$/.match(input_filename) or
          input_filename = Tempfile.open([filename, ".xml"], encoding: "utf-8") do |f|
          f.write file
          f.path
        end
      FileUtils.rm_rf dir
      ::Metanorma::Output::XslfoPdf.new.convert(input_filename,
                                                output_filename || "#{filename}.#{@suffix}", 
                                               File.join(@libdir, pdf_stylesheet(docxml)))
    end

    def xref_parse(node, out)
      target = /#/.match(node["target"]) ? node["target"].sub(/#/, ".pdf#") :
        "##{node["target"]}"
      out.a(**{ "href": target }) { |l| l << get_linkend(node) }
    end
  end
end

Version data entries

19 entries across 16 versions & 2 rubygems

Version Path
isodoc-1.2.5 lib/isodoc/xslfo_convert.rb
isodoc-1.2.4 lib/isodoc/xslfo_convert.rb
isodoc-1.2.3 lib/isodoc/xslfo_convert.rb
isodoc-1.2.2 lib/isodoc/xslfo_convert.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/isodoc-1.1.2/lib/isodoc/xslfo_convert.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/isodoc-1.2.1/lib/isodoc/xslfo_convert.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/isodoc-1.1.3/lib/isodoc/xslfo_convert.rb
isodoc-1.2.1 lib/isodoc/xslfo_convert.rb
isodoc-1.2.0 lib/isodoc/xslfo_convert.rb
isodoc-1.1.4 lib/isodoc/xslfo_convert.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/isodoc-1.1.3/lib/isodoc/xslfo_convert.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/isodoc-1.1.2/lib/isodoc/xslfo_convert.rb
isodoc-1.1.3 lib/isodoc/xslfo_convert.rb
isodoc-1.1.3.pre.alpha3 lib/isodoc/xslfo_convert.rb
isodoc-1.1.3.pre.alpha2 lib/isodoc/xslfo_convert.rb
isodoc-1.1.3.pre.alpha lib/isodoc/xslfo_convert.rb
isodoc-1.1.2 lib/isodoc/xslfo_convert.rb
isodoc-1.1.1 lib/isodoc/xslfo_convert.rb
isodoc-1.1.0 lib/isodoc/xslfo_convert.rb