Sha256: 446279785e786b28950c862bc3e0d059ae536f414cabc35714f45e9ccc0f3b4e

Contents?: true

Size: 831 Bytes

Versions: 6

Compression:

Stored size: 831 Bytes

Contents

$KCODE = 'UTF-8'

require 'tempfile'
require File.join(File.dirname(__FILE__), '..', 'html', 'html.rb')

# Depends on HTMLDOC utility (http://www.easysw.com/htmldoc/)
module Markout

  class Pdf < Formatter

    def export
      `cat "#{tempfile.path}" | /opt/local/bin/htmldoc -t pdf \
          --bodyfont "Helvetica" --headfootfont "Helvetica" \
          --no-compression --color --embedfonts \
          --header "" --footer .1. --links --no-title \
          --toctitle "" --tocheader "..." --tocfooter "..." \
          -`
    end

    private

    def tempfile
      tempfile = Tempfile.new(File.basename(@document.path) + '.html')
      content  = Markout::Html.new(@document).export
      tempfile << content.gsub(/[^\x00-\x7F]/) { |ch| "&##{ch.unpack("U")[0]};" } # From the Textmate Markdown bundle
    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
karmi-markout-0.1.1 lib/markout/formatters/pdf/pdf.rb
karmi-markout-0.1.2 lib/markout/formatters/pdf/pdf.rb
karmi-markout-0.1.3 lib/markout/formatters/pdf/pdf.rb
karmi-markout-0.1.5 lib/markout/formatters/pdf/pdf.rb
karmi-markout-0.1.6 lib/markout/formatters/pdf/pdf.rb
karmi-markout-0.1.7 lib/markout/formatters/pdf/pdf.rb