asciidocasciidoctorasciidoctor-pdf

How to add a cover image to an asciidoc document


Here is my asciidoc document header:

= My App: Software Design Document
Giuseppe Greco <giuseppe.greco@agamura.com>
v.0.1, 2024-09-18: First draft
:doctype: book
:sectnums:
:toc:
:toclevels: 4
:description: Software Design Document
:imagesdir: ./images
:appname: myApp
:front-cover-image: image::cover-page.svg[alt="Cover Page", width=600, height=400, align="center"]

I want to add a cover page before any other page... but unfortunately the front-cover-image directive above doesn't work. cover-page.svg is located in imagesdir. Am I missing something?


Solution

  • For Asciidoctor PDF, you have two choices:

    1. Configure the title page in your AsciiDoc content: https://docs.asciidoctor.org/pdf-converter/latest/title-page/

    2. Configure your theme:

      1. to use a cover: https://docs.asciidoctor.org/pdf-converter/latest/title-page/
      2. to use a title page: https://docs.asciidoctor.org/pdf-converter/latest/theme/title-pages/

    As Richard Smith commented, you likely need to use an inline image instead of a block image, so image: instead of image::.