sphinx-contrib / plantuml

BSD 2-Clause "Simplified" License
115 stars 42 forks source link

Building rst2pdf fails as pdf is not recognised as an image #77

Closed jack-burridge-cfh closed 4 months ago

jack-burridge-cfh commented 1 year ago

I get the error:

[ERROR] image.py:296 The image (/Users/jack.burridge/Dev/doc/_build/pdf/plantuml-efcc6fe13950140bb2f115b0c88457c46fab1a6c.pdf, near line UNKNOWN in file UNKNOWN) is broken or in an unknown format

I'm using

sphinxcontrib-plantuml==0.25
rst2pdf==0.100
Sphinx==7.0.1
jack-burridge-cfh commented 1 year ago

I have a minimal example that triggers the same error: minimal.zip

droppedbars commented 4 months ago

I've run across this same issue. Editing sphinx.py pdf_visit_plantuml if I change 'pdf' to 'svg' on line 762 and remove line 763, it renders fine.

I don't know if this is something that used to work with rst2pdf or not, but it seems it should use a different format once it sees 'rst2pdf.pdfbuilder' in the list of extensions. From what I can tell, rst2pdf is unable to embed pdfs as an image in a doc.

Alternatively, one could if it sees that options skip rendering at ll and instead require configuring the rst2pdf plantuml extension, but I haven't yet figured out how to push that through sphinx-build (it works on the commandline)

EDIT: I should have said on line 762 if I change eps to svg.

yuja commented 4 months ago

I've run across this same issue. Editing sphinx.py pdf_visit_plantuml if I change 'pdf' to 'svg' on line 762 and remove line 763, it renders fine.

I don't remember why it's hard-coded to 'eps', but it might be because .eps is the only vector format supported by pdf generator at that time. (as you might know, .pdf, .eps, and .ps belong to the same family of file formats.) If 'svg' works, it's probably okay to switch to it.

droppedbars commented 4 months ago

In my local hack changing to svg appears to work. It looks like the code (not my hack) is generating PDFs from the PlantUML and attempting to embed them as images into the rst files, and then rst2pdf can't handle that.

droppedbars commented 4 months ago

Created a PR: https://github.com/sphinx-contrib/plantuml/pull/93

If everyone things changing the behaviour. If original behaviour should persist then a config flag could be added instead to support changing the behaviour to use other rendering options.