Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to merge multiple SVGs files on a html page?

Tags:

svg

I have been trying to merge two SVG files into single SVG file. Everywhere I found is using pageSet. Below code is to merge two SVG file to a single file.

<pageSet>
    <page>
        <circle cx="300" cy="150" r="90" fill="red" stroke="black"
                stroke-width="4" fill-opacity="0.7" />
    </page>
    <page>
        <circle cx="240" cy="250" r="90" fill="green" stroke="black"
                stroke-width="4" fill-opacity="0.7" />
    </page>
    <page>
        <circle cx="360" cy="250" r="90" fill="blue" stroke="black"
                stroke-width="4" fill-opacity="0.7" />
    </page>
</pageSet>

I tried using the above code but, nothing is displaying.

like image 888
Dalee Avatar asked Jul 27 '12 08:07

Dalee


People also ask

How do I combine multiple SVGs into one?

To merge multiple SVG files together, upload your vectors or drag n drop them to the editor. Next, place the files together either vertically, horizontally, or at any position. After you're done editing, download the merged SVG in multiple high-res formats.

Can I have multiple SVG images in a single file?

Yes. What is the issue your having? @JeremyA. West Added XML version, encoding, and SVG Doctype for the external file.


1 Answers

You can embed SVG files in an HTML document, one after another. For example, with either the SVG content inline:

<html><head>…</head><body>
  <svg xmlns="http://www.w3.org/2000/svg"><!-- SVG Data --></svg>
  <svg xmlns="http://www.w3.org/2000/svg"><!-- SVG Data --></svg>
  <svg xmlns="http://www.w3.org/2000/svg"><!-- SVG Data --></svg>
  <svg xmlns="http://www.w3.org/2000/svg"><!-- SVG Data --></svg>
</body></html>

…or referencing an external file:

<html><head>…</head><body>
  <object type="image/svg+xml" data="file1.svg"></object>
  <object type="image/svg+xml" data="file2.svg"></object>
  <object type="image/svg+xml" data="file3.svg"></object>
  <object type="image/svg+xml" data="file4.svg"></object>
</body></html>

You can then use CSS to control the page breaks when printing:

svg, object { page-break-before:always }
like image 154
Phrogz Avatar answered Nov 15 '22 10:11

Phrogz