Skip to content

Commit

Permalink
resolves #254 support writing to STDOUT (and other IO objects)
Browse files Browse the repository at this point in the history
- use Prawn's Document#render method if the target responds to the write method
- wrap STDOUT to adapt it to work with Prawn / PDF Core
  • Loading branch information
mojavelinux committed Jul 28, 2015
1 parent 0e02a46 commit 8d8f9d2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/asciidoctor-pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2052,11 +2052,18 @@ def add_outline_level outline, sections, num_levels, page_num_labels, numbering_
end

def write pdf_doc, target
pdf_doc.render_file target
if target.respond_to? :write
require_relative 'core_ext/quantifiable_stdout' unless defined? ::QuantifiableStdout
target = ::QuantifiableStdout.new STDOUT if target == STDOUT
pdf_doc.render target
else
pdf_doc.render_file target
# QUESTION restore attributes first?
@pdfmarks.generate_file target if @pdfmarks
end
# write scratch document if debug is enabled (or perhaps DEBUG_STEPS env)
#get_scratch_document.render_file 'scratch.pdf'
# QUESTION restore attributes first?
@pdfmarks.generate_file target if @pdfmarks
nil
end

def register_fonts font_catalog, scripts = 'latin', fonts_dir
Expand Down

0 comments on commit 8d8f9d2

Please sign in to comment.