require "isodoc"
require "isodoc/rsd/pdf_convert"
require_relative "metadata"
module IsoDoc
module Vsd
# A {Converter} implementation that generates PDF HTML output, and a
# document schema encapsulation of the document for validation
class PdfConvert < IsoDoc::Rsd::PdfConvert
def vsd_html_path(file)
File.join(File.dirname(__FILE__), File.join("html", file))
end
def initialize(options)
super
@htmlstylesheet = generate_css(vsd_html_path("htmlstyle.scss"), true, default_fonts(options))
@htmlcoverpage = vsd_html_path("html_vsd_titlepage.html")
@htmlintropage = vsd_html_path("html_vsd_intro.html")
@scripts = vsd_html_path("scripts.html")
system "cp #{vsd_html_path('logo.png')} logo.png"
@files_to_delete << "logo.png"
end
def default_fonts(options)
b = options[:bodyfont] ||
(options[:script] == "Hans" ? '"SimSun",serif' :
'"Overpass",sans-serif')
h = options[:headerfont] ||
(options[:script] == "Hans" ? '"SimHei",sans-serif' :
'"Overpass",sans-serif')
m = options[:monospacefont] || '"Space Mono",monospace'
"$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"
end
def html_head()
<<~HEAD.freeze
HEAD
end
def make_body(xml, docxml)
body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
xml.body **body_attr do |body|
make_body1(body, docxml)
make_body2(body, docxml)
make_body3(body, docxml)
end
end
end
end
end