asciidoctorasciidoctor-pdf

In asciidoc how do I execute a macro only for pdf generation?


In the asciidoc there is an image that I'd like to include only for PDF output. Is there a kind of attribute I can pass to image:: so that the image is processed for PDF generation, and ignored when generating epubs etc.? Or more probably by using ifdef, but how exactly?


Solution

  • You can use the ifdef directive like this:

    Some text for all outputs.
    
    ifdef::backend-pdf[]
    This is only displayed in the PDF document, you can use image:
    image::mypict.png[]
    endif::[]