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 ma...@iworks.fr on 2003/12/05 16:27:03 UTC

SVG scaling issue (when rendering 2 SVGs of same height)

Hello,

I'm trying to render a pdf containing external svg graphics and I 
encounter a scaling problem.
I know this topic was already discussed, but I want to know if there's 
something new.

I put two SVGs in a table, in the same row, in two cells. These SVG have 
the same height, but different widths. But in the pdf they have a 
different size.
These SVG are quite plain (rectangles). They were created with Adobe 
Illustrator, they contain a "path" element. If I use a svg containing a 
"rect" element, the problem disapears. If I use a bitmap graphic too.

I've tried to change some attributes (width, height...) of the 
fo:external-graphic tag but it doesn't work better. 

I've joined the two SVGs, the xsl-fo file and the resulting pdf (it's not 
too big).

Any idea ?

Thanks.

Here's the fo tree :

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <fo:layout-master-set>
    <fo:simple-page-master
          margin-right="1cm"
          margin-left="1cm"
          margin-bottom="2cm"
          margin-top="1cm"
          page-width="21cm"
          page-height="29.7cm"
        master-name="first">
                <fo:region-body/>
    </fo:simple-page-master>
  </fo:layout-master-set>

  <fo:page-sequence master-reference="first">
    <fo:flow flow-name="xsl-region-body">
                        <fo:block>
                                <fo:table table-layout="fixed" 
height="30mm">
                                        <fo:table-column 
column-width="25mm"/> 
                                        <fo:table-column 
column-width="25mm"/>  
                                        <fo:table-body> 
            <fo:table-row height="30mm">
                <fo:table-cell>
                        <fo:block>
                                <!-- green rectangle -->
                                <fo:external-graphic 
src="url('green_rect.svg')"  />
                        </fo:block> 
                </fo:table-cell> 
                <fo:table-cell>
                        <fo:block>
                                <!-- rose rectangle -->
                                <fo:external-graphic 
src="url('rose_rect.svg')" />
                        </fo:block> 
                </fo:table-cell> 
            </fo:table-row> 
          </fo:table-body>
                                </fo:table>
        </fo:block>
    </fo:flow>
  </fo:page-sequence>
</fo:root>


Re: SVG scaling issue (when rendering 2 SVGs of same height)

Posted by Martin Regner <m....@dievision.de>.
I think, i don't understand fully the problem you have, but since i had to 
embed different sized Logos in some pdf Document and there was a lot of 
problems with transparency with all graphic-formats except svg, i patched th 
PDFRenderer of fop. So i can do something like that.

    <xsl:template match="logos">
        <fo:block text-align="center" vertical-align="middle" 
border-style="solid">
            <fo:inline>
            <xsl:for-each select="logo">
                <fo:external-graphic width="80pt" height="50pt">
                    <xsl:attribute name="src"><xsl:value-of select="@src"/></
xsl:attribute>
                </fo:external-graphic>
            </xsl:for-each>
            </fo:inline>
        </fo:block>
    </xsl:template>

The Problem may be, that th scaling don't change the ratio of the svg's. So 
the width and height attributes only define a bounding box in which the svg 
is scaled. So if your svg is 15 x 150 then (depending on the sample above) it 
will be scaled to somthing like 5 x 50. I don't know, if that helps you, but 
i can send you my fop.jar if you like.

Martin
-- 
Dievision GmbH | Kriegerstrasse 44 | 30161 Hannover
Telefon: (0511) 288791-0 | Telefax: (0511) 288791-99
http://www.dievision.de | mailto:m.regner@dievision.de


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