zhaoterryy / mkdocs-pdf-export-plugin

An MkDocs plugin to export content pages as PDF files
MIT License
313 stars 44 forks source link

Problem adding images #92

Closed Elvander closed 3 years ago

Elvander commented 3 years ago

On the output PDF I have an issue with the images not being loaded.

ERROR - Relative URI reference without a base URI: <img src="/images/nl_signage_bewerk_widget.png">

I'm running version 0.5.8.

This appeared to be solved in the 0.5.1b https://github.com/zhaoterryy/mkdocs-pdf-export-plugin/issues/28#issuecomment-457240296

majkinetor commented 3 years ago

I am having the same problem. Images are not shown in PDF output. Currently using 0.5.8, but it stopped few versions back.

Here is reproducible demo. It shows in build:

https://ci.appveyor.com/project/majkinetor/mm-docs-template#L61

ERROR: Relative URI reference without a base URI: <img src="/mm-docs-template/files/omg-lolcat.jpg">

Here are the artifacts:

  1. Demo page: https://majkinetor.github.io/mm-docs-template/demo/#local-files
  2. PDF: https://majkinetor.github.io/mm-docs-template/demo/demo.pdf#page=3

    • details on page 3 ![image](https://user-images.githubusercontent.com/85767/106045703-96de6f00-60e1-11eb-84bc-22394773f450.png)

This is the full code for docker image: https://github.com/majkinetor/mm-docs

It worked before, not sure when it stopped. The only suspicious thing in the build output is:

/usr/lib/python3.6/site-packages/weasyprint/document.py:36: UserWarning: There are known rendering problems and missing features with cairo < 1.15.4. WeasyPrint may work with older versions, but please read the note about the needed cairo version on the "Install" page of the documentation before reporting bugs. http://weasyprint.readthedocs.io/en/latest/install.html

Elvander commented 3 years ago

I've found the reason. The path for the image's while generating the PDF's is relative to the path of the md-file.

If you link the images relative to the md file the PDF generation works

![Pagina aanmaken](../../../images/signage/nl_signage_incident_aanmaak.png) instead of ![Pagina aanmaken](/images/signage/nl_signage_incident_aanmaak.png)

I hope this helps others with the same issue!