asciidoctor-gradle-plugin icon indicating copy to clipboard operation
asciidoctor-gradle-plugin copied to clipboard

Documentation or example for Ditaa with asciidoctorPdf task

Open msgilligan opened this issue 5 years ago • 6 comments

I'm having trouble getting a Ditaa diagram to render correctly in the PDF format. I'm using the asciidoctorPdf task.

Issue #450 reported the same problem, but was closed without explanation. The example in https://github.com/ixchelruiz/asciidoctor-gradle-diagram works for me, but it doesn't use the asciidoctorPdf task. The documentation does not (directly) explain how to do this nor is there an example using the asciidoctorPdf task.

msgilligan avatar Dec 16 '19 20:12 msgilligan

Can you drop a snippet of your gradle build file in here?

ysb33r avatar Dec 17 '19 10:12 ysb33r

The project is open source, but I haven't pushed the build file to Github yet since it doesn't work. Here's what I'm starting with:

buildscript {
    repositories {
        jcenter()
    }
}

plugins {
    id 'org.asciidoctor.jvm.convert' version '2.4.0'
    id 'org.asciidoctor.jvm.pdf' version '2.4.0'
}

repositories {
    jcenter()
}

def buildDocDir = file('build/doc')

asciidoctorj {
    modules {
        diagram.version '1.5.18'
    }
}

asciidoctor {
  sourceDir file("$projectDir")
  sources {
    include 'PaymentChannelResearch.adoc', 'RGBProtocolOverview.adoc'
  }
  outputDir  buildDocDir
}

asciidoctorPdf {
  sourceDir file("$projectDir")
  sources {
      include 'PaymentChannelResearch.adoc', 'RGBProtocolOverview.adoc'
  }
  outputDir  buildDocDir
}

task renderAll(dependsOn: [asciidoctor, asciidoctorPdf])

msgilligan avatar Dec 17 '19 21:12 msgilligan

Do not write the output of both tasks to the same folder. If you want that, rather create a Copy/Sync task that will sync from both tasks to a common folder.

ysb33r avatar Dec 17 '19 22:12 ysb33r

Do not write the output of both tasks to the same folder. If you want that, rather create a Copy/Sync task that will sync from both tasks to a common folder.

I changed the output to separate folders and the problem remains. I believe the problem is specific to the Ditaa format which has different image-path processing than PlantUML, which works correctly.

Here 's the section of the PDF that shows the problem:

Screen Shot 2019-12-18 at 2 55 38 PM

msgilligan avatar Dec 18 '19 23:12 msgilligan

Mmm.. I've seen that before, but cannot recall how I solved it. I'll try look into this over the weekend.

In the mean-time, maybe

asciidoctorPdf {
  useIntermediateWorkDir()
}

might help.

ysb33r avatar Dec 18 '19 23:12 ysb33r

asciidoctorPdf {
  useIntermediateWorkDir()
}

might help.

That didn't seem to help. You can see the full project and the Github Actions build here: https://github.com/msgilligan/Research/commit/f9d38fda17d8d07966455fc5efe5e3aa2b7ea217/checks?check_suite_id=365725075

If you look in the archive you can see that the rendered image wasn't included in the PDF. And you can also see the error message for the missing image on line 114:

asciidoctor: WARNING: image to embed not found or not readable: /home/runner/work/Research/Research/diag-1d92173716e045e7243d9800988c027c.png

msgilligan avatar Dec 19 '19 00:12 msgilligan