Kozea / Kozea/CairoSVG

Cannot export objects with a specified id

Open
#332 5 comments 0 reactions 0 assignees View on GitHub
feature
Dominant language
Python
Stars
951
Forks
166
PR merge metrics
No merged PRs in 30d

Description

I have a svg document that contains an icon set. For each icon there is a rect with a specific `id` that defines the bounding box of the icon to be exported. With inkscape I can export individual icons as follows:

inkscape --export-filename icon101.png --export-id=icon101 all_icons.svg

Is this possible with CairoSVG? I have noticed that I can add a #fragment to the input file/url, and was hoping I could use this to specify the id of the object to export, but that fails:

```
$ cairosvg -f png -o icon101.png 'all_icons.svg#icon101'

Traceback (most recent call last):
[...]
TypeError: Root node is rect. Should be one of marker, svg, image, or g.
```

Is this use case supported?

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the CairoSVG CLI command against all_icons.svg, using the #icon101 fragment and the --export-id workflow described in the issue. Trace fragment handling through the export entry point and check how a selected rect becomes the root node. Done means exporting an object by id produces the requested output instead of the root-node TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.