The PDF opens and the caption is there, but the figure is missing. If the same Markdown worked from your docs folder, compare working directories before changing PDF engines. In this lab, the conversion succeeded without the image and a text-only check passed.

1. Start with one small document

Put the Markdown file in a docs folder and the PNG in docs/figures. From inside report.md, reference figures/signal.png. That will make sense to editors opening the document in its own folder. The next step is to make the build use that same resource directory.

The Markdown is under docs, with its PNG under docs/figures.

Use any local PNG for the sample. The sentence below is also a diagnostic marker:

--- title: "Release Check" --- # Delivery note  The Parcel 17 check passed. ![Signal chart for Parcel 17](figures/signal.png){width=68%} 

2. Watch what changes when CI runs the command

The command can find docs/report.md while still overlooking that document’s image. During PDF or embedded-HTML generation, Pandoc’s default resource lookup starts at the process’s working directory. Giving it the path to the Markdown does not, by itself, move the process into docs.

The repository-root invocation searches the wrong figures directory by default.

The Pandoc manual spells out where the converter looks for images. Before changing a pipeline, check what the CI step uses as its working directory.

3. Reproduce the silent-looking failure

From the project root, the embedded-HTML build warned about the missing PNG but still returned exit code zero without strict mode. Adding --fail-if-warnings made the same check return three in this lab. The warning matters even if there’s already an artifact on disk, because that may be an incomplete file or an older copy.

The actual missing-resource warning was emitted in the lab, and strict mode returned exit code 3.

Run this from the project root, not from docs:

mkdir -p output pandoc docs/report.md -s -t html --embed-resources -o output/without-image.html 

Keep the failing build under a different name to compare it with the corrected one.

4. Pick the PDF route after the input works

Pandoc delegates page rendering to a PDF engine. If XeLaTeX and its packages are working, the direct route is short. This Linux sandbox had the xelatex binary but not its format, so I did not use that route to claim a passing PDF. I tested Pandoc’s standalone embedded HTML and LibreOffice’s actual PDF export instead. You can use your browser’s Print to PDF on the embedded HTML if you don’t need a headless build.

Pandoc delegates PDF output to an engine; embedded HTML can be printed separately instead.

If XeLaTeX is installed and configured, the direct command documented by Pandoc’s PDF options is:

pandoc docs/report.md --pdf-engine=xelatex --resource-path=docs --fail-if-warnings -o output/report.pdf 

A missing engine or TeX package is a different issue. A resource path will not install or fix the engine.

5. Add a resource path that matches the link

Use --resource-path=docs from the project root, since report.md already includes figures/ in the image link. Setting docs/figures here would ask Pandoc to look for figures inside figures. If you also need the original working directory, explicitly include it: .:docs on Linux and macOS, or .;docs on Windows. Quote the Windows value in PowerShell.

Add the directory containing figures, not the figures directory itself, because Markdown already contains figures/ in the path.

Alternatively, change into the document’s directory first if all of the resources live under it:

(cd docs && pandoc report.md -s -t html --embed-resources --fail-if-warnings -o ../output/report.html) 

6. Make a document you can move or print offline

Standalone HTML has a document wrapper but can still reference external files. For this local image, --embed-resources stored a data URI directly in the HTML. That means moving the HTML into an output folder won’t strand the figure. For an offline build, keep inputs local rather than adding web URLs that the converter would need to fetch.

HTML that references figures/signal.png still needs external files; the embedded output carries the PNG in a data URL.

This command produced the working HTML from the project root:

pandoc docs/report.md -s -t html --embed-resources --resource-path=docs --fail-if-warnings -o output/report.html 

Open the HTML and use your browser's Print to PDF, or use Writer/Web for a headless check:

soffice --headless --convert-to 'pdf:writer_web_pdf_Export' --outdir output output/report.html 

Use the PDF engine and font bundle your team intends to ship. The tested lab used Pandoc 3.1.11.1 and LibreOfficeDev 26.8 alpha on Linux, not a browser print run or a Windows test.

7. Open the actual PDF twice

The PDF on the left has the paragraph and caption, which is why a quick skim can miss this bug. The one on the right restores the bar chart. Both were rendered from actual PDF exports in the lab. Both commands requested an embedded image. The change that made the second one work was adding the correct resource directory.

Two real PDF renders: the first contains the title and caption only; the second includes a four-bar chart.

8. Add two checks to CI

In the lab, pdftotext found the marker sentence in both the broken and corrected PDFs. Counting PDF images separately caught the missing raster figure. The one-image assertion is suitable for this fixture; don’t apply it unchanged to a PDF that uses vectors, vector charts or scans. Review the rendered page when placement, content or appearance matters.

Both PDFs passed the text test; only the corrected PDF contained one raster image.

With Poppler installed, check the PDF you actually plan to publish:

pdftotext output/report.pdf - | grep -F 'The Parcel 17 check passed.' pdfimages -list output/report.pdf 

A missing file should fail the step even before these checks. Use a fresh output directory in CI, and do not publish a previous build’s PDF after a command fails.

9. If you also need something people can edit

The second verified route sends Markdown to DOCX with the same resource path, then opens the DOCX in LibreOffice Writer and exports PDF. It preserved the PNG in this fixture. It is convenient when somebody needs to revise the document in a word processor, but pagination and typography may differ from the direct engine route.

The fallback uses Pandoc to create a DOCX with the PNG, then exports that DOCX with Writer.

The Pandoc manual describes using a word processor after intermediate DOCX output. Here is the route I ran on the same sample:

pandoc docs/report.md --resource-path=docs --fail-if-warnings -o output/report-editable.docx soffice --headless --convert-to pdf --outdir output output/report-editable.docx 

A build that starts in the right directory, fails on warnings, and checks one real figure is easier to trust than one that merely reports “PDF created.”

Visuals: original diagrams and renders of two PDFs generated from synthetic lab data.