Hi eLECTRIC,
eLECTRIC - wrote:
I want to import the svg as a element of my xml and send it all straight
to the FOP renderer to output a PDF without saving anything to disk
(only the final PDF).
Did you know that you can output just SVG to a PDF? You can
bypass FO if you want to? Of course this way you can only generate
a single page.
After creating the chart I do the chart.draw() to the SVGGraphics2D then
I import the element using document.importNome on the svgG2.getRoot()
and appending the imported child to my original XML document (all goes
well, the xmlns for the svg tag is removed on that import).
I would be _very_ surprised if the svg element moved out of the
SVG NS when it is imported, this would be a fairly broken implementation
of 'importNode'.
Now I pass that document to the be transformed to fo with XSLT. So I
have a fo:instream-foreign-object tag in my XSL and inside of it I do a
<xsl:copy-of select="/original/svg"/>. If the svg has no xmlns tag this
operation works but when I try to FOP it to PDF I get a namespace
problem. If I force the imported tag to have a xmlns tag (using
importedElement.setAttribute("xmlns", "blablabla") then the copy-of
returns empty.
I also tried to use xmlns:svg instead of xmlns and add prefix to the
root svg tag or recursively to all the child tags and that didn't seem
to work also.
Well I'm really not much of an XSLT man, but when you
added the prefix did you change the select to "original/svg:svg"
this has always worked for me. IIRC you need to declare the
prefixs in your XSLT also (using xmlns:svg on the root
stylesheet element).
I have noticed that since the output svg file has no width and
height tags the rendered image is cropped to a small square, then
again if I manually insert the width and height attributes to the
svg file all works nice.
I tried something like svgG2.getRoot().setAttribute("width", "123")
before the stream to file but the resulting svg is empty.
Is there a easy or at least a working way to do what I need?
Calling 'getRoot()' clears the drawing tree from the SVG
Graphics2D (it gives it to you) so any subsequent calls will
return an empty tree (unless you have drawn something since the
last call to getRoot. Anyway the proper way to set the 'width' and
'height' on the generated SVG is with:
'SVGGraphics2D.setSVGCanvasSize(Dimension)'
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]