xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathan wood <jonathanshaww...@gmail.com>
Subject Re: Combine SVG out of single SVG files
Date Wed, 22 Jun 2011 15:13:06 GMT
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 <dennis.kuehn@tu-dortmund.de
> 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: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>

Mime
View raw message