You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Tommy Reynolds <To...@MegaCoder.com> on 2005/04/01 03:15:19 UTC

Help with external SVG graphic

I have an XSL-FO snippet:

<fo:block xmlns:xlink="http://www.w3.org/1999/xlink" space-after="14pt">
	<fo:external-graphic src="syscall.svg" left="6pt" right="6pt" 
		width="4in" height="1.6in" />
</fo:block>

with this SVG file:

<?xml version="1.0"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
              "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
          <!ENTITY  bgColor "rgb( 19, 67, 97 )"                       >
          <!ENTITY  fgColor "rgb( 198, 173, 39 )"                     >
          <!ENTITY  canvas  "white"                                   >
]>
<svg viewBox="0 0 725 250" xmlns="http://www.w3.org/2000/svg" version="1.1">
  <title>System Calls</title>
  <desc>Us versus them.</desc>
  <defs>
    <path d="M 0,0 l 25,-10 0,20 z" fill="&fgColor;" id="arrowhead"/>
    <path id="arc" d="m 0,0 a 250,250, 0 0 1 200,0"/>
    <path id="darc" d="m 0,0 a 250,250 0 0 0 200,0"/>
  </defs>
  <!-- background canvas outline    -->
  <path d="M 0,0 l 725,0 0,250 -725,0 z" fill="&canvas;" stroke="none"/>

  <!-- content -->
  <g fill="none" stroke="&fgColor;" stroke-width="4">
    <path d="M 1,1 l 250,0 0,200 -250,0 z" />
    <path d="M 450,1 l 250,0 0,200 -250,0 z" />
    <use xlink:href="#arc" transform="translate( 250, 50 )"/>
    <use xlink:href="#arrowhead" transform="translate( 450,50 ) rotate( 200 )"/>
    <use xlink:href="#darc" transform="translate( 250, 75 )"/>
    <use xlink:href="#arrowhead" transform="translate( 250,70 ) rotate( 30 )"/>
    <use xlink:href="#darc" transform="translate( 250, 180 )"/>
    <use xlink:href="#arrowhead" transform="translate( 250,175 ) rotate( 30 )"/>
  </g>
  <g font-family="&apos;Courier New&apos;, Courier, Verdana, Helvetica, sans-serif" font-size="64" fill="&fgColor;" stroke="&fgColor;" stroke-width="0.5">
    <text text-anchor="middle" x="120" y="120">APP</text>
    <text text-anchor="middle" x="575" y="120">KERNEL</text>
  </g>
  <g fill="&fgColor;" font-family="Courier New, Courier, Verdana" font-size="32" stroke="&fgColor;" stroke-width="0.5">
    <text transform="translate( 250, 40 )">
      <textPath xlink:href="#arc" startOffset="18%">
      SYSCALL
      </textPath>
    </text>
    <text transform="translate( 250, 110 )">
      <textPath xlink:href="#darc" startOffset="20%">
        Return
      </textPath>
    </text>
    <text transform="translate( 250, 210 )">
      <textPath xlink:href="#darc" startOffset="25%">
        Signal
      </textPath>
    </text>
  </g>
</svg>

The problem is that FOP renders this as an extremely tiny graphic.  If I try to import the .PNG version of this (rendered by either batik or rsvg) the bounding box is square instead of having the aspect ratio of the real graphic.

Can anybody suggest how to fix either the SVG or PNG import using FOP?

Thanks!

Re: Help with external SVG graphic [SOLVED]

Posted by Tommy Reynolds <To...@MegaCoder.com>.
Uttered "J.Pietschmann" <j3...@yahoo.de>, spake thus:

> Tommy Reynolds wrote:
> > I have an XSL-FO snippet:
> > <fo:block xmlns:xlink="http://www.w3.org/1999/xlink" space-after="14pt">
> > 	<fo:external-graphic src="syscall.svg" left="6pt" right="6pt" 
> > 		width="4in" height="1.6in" />
> > </fo:block>
> > with this SVG file:
> > <svg viewBox="0 0 725 250" xmlns="http://www.w3.org/2000/svg" version="1.1">
> > The problem is that FOP renders this as an extremely tiny graphic.
> This has something to do with negotiating the view box between FOP and
> the SVG renderer (Batik), and the fact that you didn't supply width
> and heigt for the SVG itself. Just adding w&h to the SVG top level
> should fix this:

Adding explicit heights only provided marginal improvement.

But when I used batik to render to a .jpg file, a native FOP format,
the image looked much better.

Thanks

Re: Help with external SVG graphic

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Tommy Reynolds wrote:
> I have an XSL-FO snippet:
> 
> <fo:block xmlns:xlink="http://www.w3.org/1999/xlink" space-after="14pt">
> 	<fo:external-graphic src="syscall.svg" left="6pt" right="6pt" 
> 		width="4in" height="1.6in" />
> </fo:block>
> 
> with this SVG file:
...
> <svg viewBox="0 0 725 250" xmlns="http://www.w3.org/2000/svg" version="1.1">
...
> The problem is that FOP renders this as an extremely tiny graphic.

This has something to do with negotiating the view box between FOP and
the SVG renderer (Batik), and the fact that you didn't supply width
and heigt for the SVG itself. Just adding w&h to the SVG top level
should fix this:
  <svg viewBox="0 0 725 250" xmlns="http://www.w3.org/2000/svg"
    width="4in" height="1.6in" version="1.1">
For best results, you should always specify the same width and height
both on the SVG document element and on the fo:external-graphic element.

J.Pietschmann

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org