plantuml icon indicating copy to clipboard operation
plantuml copied to clipboard

Building rst2pdf fails as pdf is not recognised as an image

Open jack-burridge-cfh opened this issue 2 years ago • 1 comments

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 avatar Jul 01 '23 09:07 jack-burridge-cfh

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

jack-burridge-cfh avatar Jul 05 '23 08:07 jack-burridge-cfh

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.

droppedbars avatar May 17 '24 19:05 droppedbars

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.

yuja avatar May 18 '24 01:05 yuja

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 avatar May 18 '24 05:05 droppedbars

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.

droppedbars avatar May 19 '24 22:05 droppedbars