No images in generated PDF document (from Asciidoc to PDF)

2.5k views Asked by At

I'm generating a PDF document from asciidoc with asciidoctor-web-pdf. So far most tasks work fine.

asciidoctor-web-pdf -a stylesheet="asciidoctor-pdf/css/asciidoctor.css,asciidoctor-pdf/css/document.css,assets/pdf-export/custom.css" \
                    -a stem \
                    --require asciidoctor-kroki \
                    docs/modules/ROOT/pdf.adoc

But my document does not include images or generated diagrams (plantuml).

The folder structure follows the layout of Antora because I mainly use Antora. The PDF is just a necessary side-product.

My folder structure looks like this (as said antora-layout):

project-folder
+ docs
| + modules
| | + ROOT
| | | + assets
| | | | + images
| | | | | - logo.png
| | | + pages
| | | | - index.adoc
| | | | - 01-intro.adoc
| | | | - some-other.adoc
| | | - nav.adoc
| | | - pdf.adoc

The pdf.adoc is just a list of includes to make sure every needed adoc file is part of the PDF.

According to the folder structure the correct path to my logo.png is docs/modules/ROOT/assets/images/logo.png (or absolute /home/sebastian/work/workspace/workspace-p/jira-ops-manual/docs/modules/ROOT/assets/images/logo.png).

When I generate the PDf with above command I get these errors:

  1. normal image
Failed to load resource: net::ERR_FILE_NOT_FOUND at file:///home/sebastian/work/workspace/workspace-provinzial/jira-ops-manual/docs/modules/ROOT/logo-provinzial.png:1
  1. plantuml diagram
asciidoctor: ERROR: pages/04-system-setup/index.adoc: line 8: include file not found: /home/sebastian/work/workspace/workspace-provinzial/jira-ops-manual/docs/modules/ROOT/pages/04-system-setup/image$04-system-setup/system-overview.puml

I guess the problem is that asciidoctor-web-pdf doesn't subsitute the image$... part of the path so the reference is wrong (or in general cannot resolve these references). Images and diagrams are embedded like this:

image::logo.png[Logo, align="center"]

[plantuml, system-overview-plantuml-image, svg]
----
include::image$04-system-setup/system-overview.puml[]
----

Does anyone have a hint how to solve my issue? I'm open to other solutions as well. Maybe there is a simpler way with antora so I don't need asciidoctor-web-pdf at all?


EDIT: I solved the problem with normal images by setting the images path at the top of the pdf-adoc.

= Operations Manual
:imagesdir: ./assets/images

include::pages/index.adoc[]

include::page1.adoc[]

include::page2.adoc[]

...

But the problem with the plantuml images still exists.

:imagesdir: ./assets/images

1

There are 1 answers

0
Frank Blome On

First, I would write a comment but I haven't 50 reputations - So I answer… sort of:

You have to know asciidoc-web-pdf is still under active development and I can't imagine it isn't well tested beside Antora. In this discussion you'll get some insights: https://discuss.asciidoctor.org/Single-PDF-and-multiple-HTML-from-same-sources-td7640.html

That being said, I would reduce complexity (build my stuff out if Antora) and start building in little steps. Then succeed to the next step.