W3C home > Mailing lists > Public > www-xsl-fo@w3.org > August 2008

Size of imported SVG Graphics in PDF output

From: <david.vergnaud@finnova.ch>
Date: Tue, 12 Aug 2008 12:07:45 +0200
Message-ID: <696E9A46BED8E544A7BD2C20A7E94F68060E1FF5@marena.SIDON.OLYMP>
To: <www-xsl-fo@w3.org>

Hi,

I'm pretty new to FOP, so there might be some aspects I have overlooked, still I have a question about setting the size of an SVG graphic I'm importing in my FOP file for it to be rendered into a PDF file. 
I'm importing the base64-encoded SVG data in FOP using fo:external-graphic

It looks a bit like this:

  <fo:page-sequence master-reference="section1-page-sequence-master" format="1">
    <fo:flow flow-name="xsl-region-body">
      <fo:block widows="2" orphans="2" font-size="10pt" line-height="1.147" white-space-collapse="false">
        <fo:block font-family="TimesNewRoman" font-size="12pt" language="EN-GB">
          <fo:external-graphic  content-width="453.55pt" content-height="210.75pt" background-color="#DDDDDD" 
              src="url(&quot;data:image/svg+xml;base64,PHN2ZyB4bWxucz0i....
	....dmc+Cg==&#xA;&quot;)"
          />
        </fo:block>
      </fo:block>
    </fo:flow>
  </fo:page-sequence>

The original SVG file starts like this:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 21600 21600">

The SVG file is properly rendered, but FOP doesn't seem to really take the size into account. Using the background-color attribute, I've noticed that the "background area" behind the graphic is always square, and its size ("height" *and* "width") seems to be depending solely on the content-height -- i.e. changing the content-width doesn't lead to any change in the display size, while changing the content-height does. 
I've tried changing the y-coordinate in the SVG's viewBox, surprisingly enough it didn't change the look of the graphic itself, it simply changed its y-position inside the square area FOP is putting it in -- i.e. setting e.g. the viewBox's y-max to 15000 instead of 21600 leads to the graphic being displayed roughly in the vertical middle of the square area, while for 21600 it's located at the top. 

Does anyone have any idea how I can make the bounding area fit better to the actual shape of the graphic? I remember using the same syntax to include a PNG graphic, and didn't have the same problem. 

Thx in advance!

David
Received on Tuesday, 12 August 2008 16:20:35 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 12 August 2008 16:20:37 GMT