The AsciidoctorJ PDF plugin

Minimal example
plugins {
  id 'org.asciidoctor.jvm.pdf' version '5.0.0-alpha.1'
}

asciidoc {
  publications {
    main {
      output('asciidoctorj', 'pdf')
    }
  }
}

This will make the asciidoctorPdf available to generate PDF output.

Configuring PDF themes

PDF themes are configured in the asciidocThemes extensions and have two main tenets:

pdfThemeCollections

These are directories or downloadable packages that can contain more than one theme.

pdfThemes

These are named themes, which are each related to one theme from any named collection. They are used by PDF output formatters to tie a specific theme to an output.

Local themes

import org.asciidoctor.gradle.model5.core.pdfthemes.LocalThemeCollection

asciidocThemes {
    pdfThemeCollections {
        myLocal(LocalThemeCollection) { (1)
            themeDir = 'src/pdfThemes/myLocal'  (2)
        }
    }
    pdfThemes {
        myLocal {
            fromCollection('myLocal') (3)
        }
    }
}
1 Declares a local collection called myLocal
2 Provide the directory where the themes are located. This is anything convertible to a file.
3 Create a theme that uses a theme called myLocal from the myLocal collection. In this convention it will look for a file called src/pdfThemes/myLocal/myLocal-theme.yml.

Themes from Github and Gitlab

Themes stored in repositories on Github and Gitlab can also be used.

import org.asciidoctor.gradle.model5.core.pdfthemes.GithubThemeCollection
import org.asciidoctor.gradle.model5.core.pdfthemes.GitlabThemeCollection

asciidocThemes {
    pdfThemeCollections {
        kuboaki(GithubThemeCollection) { (1)
            from {
                organisation = 'kuboaki' (2)
                repository = 'beauty-pdf-using-asciidoctor-pdf' (3)
                branch = 'master' (4)
            }
            pathInRepo = 'theme' (5)
        }
    }
    pdfThemes {
        myTheme {
            fromCollection('kuboaki') (6)
            themeName = 'mystyle' (7)
        }
    }
}
1 Declares a collection called kuboaki that can be retrieved from Github. For a Gitlab-based collection replace GithubThemeCollection with GitlabThemeCollection.
2 Declare the Github organisation or the Gitlab group namespace.
3 Declare the repository name.
4 Declare a reference. Use branch, commit or tag DSL methods to do so.
5 Declare the subpath in the downloaded package where the themes are located. This will be the same as the subpath from the repository root.
6 Declare a theme called myTheme that is related to the kuboaki collection.
7 Declare that in the collection the actual theme is called mystyle.

Using a theme

import org.asciidoctor.gradle.model5.jvm.formatters.AsciidoctorjPdf

asciidoc {
  toolchains {
    aciidoctorj {
      registeredOutputFormatters {
        pdf(AsciidoctorjPdf) {
          useTheme('default-with-font-fallbacks') (1)
          useTheme('myLocal') (2)
        }
      }
    }
  }
  publications {
    main {
      output('asciidoctorj', 'pdf')
    }
  }
}
1 Use a built-in theme.
2 Use the myLocal theme from asciidocPdfThemes.

Setting other parameters

import org.asciidoctor.gradle.model5.jvm.formatters.AsciidoctorjPdf

asciidoc {
  toolchains {
    aciidoctorj {
      registeredOutputFormatters {
        pdf(AsciidoctorjPdf) {
          useVersion('1.2.3') (1)
        }
      }
    }
  }
}
1 Use a version of asciidoctorj-pdf other than the default.