-
-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SVG Image into SVG #60
Comments
Yes, that's most definitely possible.
For example: <?php
use SVG\SVG;
$a = SVG::fromFile(__DIR__.'/a.svg');
$b = SVG::fromFile(__DIR__.'/b.svg');
$a->getDocument()->addChild($b->getDocument());
echo $a; File 'a.svg': <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<rect x="10" y="10" width="5" height="20" />
</svg> File 'b.svg': <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<circle cx="40" cy="20" r="8" />
<circle cx="80" cy="20" r="8" />
</svg> Script output (formatted): <?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect x="10" y="10" width="5" height="20" />
<svg viewBox="0 0 100 100">
<circle cx="40" cy="20" r="8" />
<circle cx="80" cy="20" r="8" />
</svg>
</svg> |
Note that if you need the output without the <?php
use SVG\SVG;
$a = SVG::fromFile(__DIR__.'/a.svg');
$b = SVG::fromFile(__DIR__.'/b.svg');
$a->getDocument()->addChild($b->getDocument());
echo $a->toXMLString(false); Moreover, if you need to place image B somewhere deeper inside image A (inside a <?php
use SVG\SVG;
$a = SVG::fromFile(__DIR__.'/a.svg');
$b = SVG::fromFile(__DIR__.'/b.svg');
$groups = $a->getDocument()->getElementsByTagName("g");
$g = $groups[0];
$g->addChild($b->getDocument());
echo $a->toXMLString(false); I hope I could answer your question (albeit a bit late). If not, feel free to reopen this issue. |
Hi there,
Is there a way to load a SVG for placement into a loaded SVG. An image inside an image.
Ideally not using xlink:href. Would very much like the produced SVG self contained.
Thanks.
The text was updated successfully, but these errors were encountered: