Re: Combine SVG out of single SVG files

jonathan wood <[email protected]>
Newsgroups gmane.text.xml.batik.user
Message-ID <[email protected]>
One way to do it...assumes the file was read and placed into a byte array by
loadMyFile() (your implementation).

All fluff and exception handling removed, but the basic sequence is:

byte[] inFIleBytes = loadMyFile();
ByteArrayInputStream bais =  new ByteArrayInputStream(inFileBytes);
SAXSVGDocumentFactory svgDocumentFactory = new
SAXSVGDocumentFactory(XMLResourceDescriptor.getXMLParserClassName());
Element inElement = svgDocumentFactory.createDocument(null,
bais).getDocumentElement();
inElement = (Element) document.importNode(inElement, true);
svgRoot.appendChild(inElement);


On Wed, Jun 22, 2011 at 9:09 AM, sweetmovesdude <[email protected]
> wrote:

> Hey everyone,
>
> I have some .svg files in a folder, each representing a single component.
> What I want is to create a 100x100 px SVG document with these components,
> e.g. the "login.svg" uses the "background_green.svg" and the
> "login_component.svg".
>
> I used Batik to create a 100x100 px document, but now wonder how I can
> "import" SVG files from a specific path, let's say
> $home/documents/components/
>
> What I have so far is
>
> ...
> String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
> DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
> Document doc = impl.createDocument(svgNS, "svg", null);
>
> Element svgRoot = doc.getDocumentElement();
> svgRoot.setAttributeNS(svgNS, "width", "100");
> svgRoot.setAttributeNS(svgNS, "height", "100");
>
>
> How can I import the SVG components and attach them to svgRoot?
>
> Thank you all for helping!
>
> --
> View this message in context:
> http://batik.2283329.n4.nabble.com/Combine-SVG-out-of-single-SVG-files-tp3616984p3616984.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.