AsciidoctorJ PDF plugin

plugins {
    id 'org.asciidoctor.jvm.pdf' version '4.0.2'
plugins {
    id("org.asciidoctor.jvm.pdf") version "4.0.2"

When applying org.asciidoctor.jvm.pdf it creates a single task of type org.asciidoctor.gradle.jvm.pdf.AsciidoctorPdfTask an extension called pdfThemes.

The default task is named asciidoctorPdf and is configured to:

  • Output source to "${buildDir}/docs/asciidocPdf".

  • Not to copy any resources to the output directory.

  • It will set also a default version for asciidoctorj-pdf artifact. To override set asciidoctorj.pdfVersion or asciidoctorPdf.asciidoctorj.pdfVersion.

The AsciidoctorPdfTask task type has the following additional methods:


Directories for custom PDF fonts. Specify a directory in any form acceptable to project.file. Using this instead of directly setting the pdf-fontsdir attribute means that Gradle will be able to check out of date status dependent on the content of this folder.


Name of the theme to use. Optional. When specifying a theme name it must match one registered via pdfThemes.

The pdfThemes extension allows for themes to be registered from local copies or downloaded from GitHub or GitLab and has been inspired by earlier work of Florian Wilhelm (@fwilhe).

Registering a local theme
pdfThemes {
    local 'basic', { (1)
        themeDir = file('themes/basic') (2)
        themeName = 'very-basic' (3)
1 Local themes are registered using the local keyword and must be provided with a name.
2 Directory for finding the theme. Specify a directory in any form acceptable to project.file.
3 Optional setting of the style name. If this is not set, the theme name provided previously will be used.
Registering a GitHub or GitLab theme
pdfThemes {
    github 'basic', { (1)
        organisation = 'fwilhe2' (2)
        repository = 'corporate-theme' (3)
        relativePath = 'resources/themes' (4)

        branch = 'master' (5)
        tag = '1.0.1' (6)
        commit = '4910271e8c3964b60e186a62f3e4339ed0752714' (7)
1 Specify a GitHub repository which contains one or more themes. (For GitLab replace github with gitlab).
2 GitHub/GitLab Organisation (or user).
3 Name of repository containing the theme(s).
4 Relative path inside the repository to where the theme is located. If not specified the theme is assumed to be in the root of the repository.
5 Specify the branch
6 Instead of a branch a tag can be used.
7 Instead of a branch or a tag, a very specific commit can be used.

If a repository contains more than one theme, then the block will need to be repeated for each theme and the name and relativePath adjusted accordingly. Gradle will however, only download the repository once.

Kotlin users can use equivalent Action-based configurations.