CairoSVG icon indicating copy to clipboard operation
CairoSVG copied to clipboard

Missing linked images and text

Open theoryshaw opened this issue 1 year ago • 6 comments

Is it possible to convert the following files into a pdf? They were created with https://blenderbim.org/ I couldn't get linked pngs to work, and text doesn't show up.

svg: https://github.com/Kozea/CairoSVG/assets/507113/a9d54c99-9ae3-4c2a-8f50-63faae67f8dc png referenced into svg: https://github.com/Kozea/CairoSVG/assets/507113/2b7a7c31-8b43-4431-8c1d-bfaf18439d90)

Here's the output.... image

What it should look like: image

theoryshaw avatar Mar 13 '24 21:03 theoryshaw

Hello!

Here’s the PDF I get

out.pdf

This result is much better than yours!

The image size is wrong, but I get the same rendering with my browsers, that’s not a problem with CairoSVG.

liZe avatar Mar 18 '24 13:03 liZe

cool!, if i can ask, what was the command line you used?

theoryshaw avatar Mar 18 '24 13:03 theoryshaw

The image size is wrong, but I get the same rendering with my browsers...

That's weird, just to be sure i downloaded the svg/png from this github issue, and it seems to render correctly in Chorme and Firefox...

https://github.com/Kozea/CairoSVG/assets/507113/cd51e13e-29e8-4454-9f15-c506dd6ad2f4

theoryshaw avatar Mar 18 '24 13:03 theoryshaw

cool!, if i can ask, what was the command line you used?

cairosvg file.svg -o file.pdf -u

I’ve just changed the name of the PNG image in the SVG file so that it can it on disk.

That's weird, just to be sure i downloaded the svg/png from this github issue, and it seems to render correctly in Chorme and Firefox...

My bad, I don’t know what I’ve done with this image!

out.pdf

liZe avatar Mar 18 '24 13:03 liZe

Thanks @liZe,

I ran it again, using your suggested command line prompt. I got the background image, but the text doesn't show up.

2024-03-18_09-30-50_Revutesty5_-_Bluebeam_Revu_x64Revu

Ryan Schultz@DESKTOP-8GRDBJI MINGW64 /d/Dropbox/Gitea_OD/Highland_Haven/Open/Models_and_CAD/BlenderBIM/drawings (main)
$ cairosvg "D:/Dropbox/Gitea_OD/Highland_Haven/Open/Models_and_CAD/BlenderBIM/drawings/test.svg" -o "D:/Dropbox/Gitea_OD/Highland_Haven/Open/Models_and_CAD/BlenderBIM/drawings/testy5.pdf" -u
_cairo_win32_scaled_font_set_metrics:GetTextMetrics: The operation completed successfully.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Python312\Scripts\cairosvg.exe\__main__.py", line 7, in <module>
  File "C:\Python312\Lib\site-packages\cairosvg\__main__.py", line 78, in main
    SURFACES[output_format.upper()].convert(**kwargs)
  File "C:\Python312\Lib\site-packages\cairosvg\surface.py", line 133, in convert
    instance = cls(
               ^^^^
  File "C:\Python312\Lib\site-packages\cairosvg\surface.py", line 225, in __init__
    self.draw(tree)
  File "C:\Python312\Lib\site-packages\cairosvg\surface.py", line 472, in draw
    self.draw(child)
  File "C:\Python312\Lib\site-packages\cairosvg\surface.py", line 404, in draw
    TAGS[node.tag](self, node)
  File "C:\Python312\Lib\site-packages\cairosvg\text.py", line 69, in text
    surface.context.font_extents())
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\cairocffi\context.py", line 1927, in font_extents
    self._check_status()
  File "C:\Python312\Lib\site-packages\cairocffi\context.py", line 107, in _check_status
    _check_status(cairo.cairo_status(self._pointer))
  File "C:\Python312\Lib\site-packages\cairocffi\__init__.py", line 87, in _check_status
    raise exception(message, status)
cairocffi.CairoError: cairo returned CAIRO_STATUS_WIN32_GDI_ERROR: b'error occurred in the Windows Graphics Device Interface'

theoryshaw avatar Mar 18 '24 14:03 theoryshaw

I suppose that it’s the same problem as #377. The bug is probably in Cairo: https://gitlab.freedesktop.org/cairo/cairo/-/issues/530

You can try to use another font and see if it works. I’ll be even easier if you can use a Linux computer.

If it doesn’t work, you can try to add a comment on Cairo’s issue and hope for an answer. 🤞🏽

liZe avatar Mar 18 '24 14:03 liZe