Re: PDF's from asciidoctor-pdf ruby gem ?

Posted by davidgamba on
URL: https://discuss.asciidoctor.org/PDF-s-from-asciidoctor-pdf-ruby-gem-tp2715p2896.html

Thanks guys,

I am almost there:

    require 'asciidoctor'
    require 'asciidoctor-pdf'
    adoc_options[:attributes]["backend"] = 'pdf'
    doc = Asciidoctor.load_file options[:file], adoc_options
    Check_document.check_broken_references(doc)
    File.open("test.html", "w+") do |file|
        file.puts doc.render
    end

I need the doc object for some processing, like checking broken references, so using convert_file doesn't work for me.

The code above works for html but when the backend is pdf I get a file with:

less test.html
#<Asciidoctor::Pdf::Converter:0x0000000190dbd8>

How do I render from the doc object into the pdf file? I also tried this without luck.

    doc.render(:to_file => "test2.pdf")

Thanks,

--David

On Tue, Mar 31, 2015 at 7:16 AM, mojavelinux [via Asciidoctor :: Discussion] <[hidden email]> wrote:
As Robert pointed out, you need to require the library explicitly when using the API. The required option is only processed by the cli (asciidoctor command), not in the API itself. You get an error because asciidoctor-pdf was never required.


Cheers,

-Dan

On Tue, Mar 31, 2015 at 9:05 AM, Robert.Panzer [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Just tried with
asciidoctor 1.5.2
asciidoctor-pdf 1.5.0.alpha.6
on JRuby 1.7.13 on Win7 and the following script worked fine for me:

require 'asciidoctor'
require 'asciidoctor-pdf'
Asciidoctor.convert_file 'test.ad', :backend => 'pdf'

Could you check if that works for you as well?

Best regards,
Robert


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/PDF-s-from-asciidoctor-pdf-ruby-gem-tp2715p2883.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/PDF-s-from-asciidoctor-pdf-ruby-gem-tp2715p2888.html
To unsubscribe from PDF's from asciidoctor-pdf ruby gem ?, click here.
NAML