Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 644989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:27:11+00:00 2026-05-13T21:27:11+00:00

First question from me; I’m currently fixing a graphing service that uses XSLFO to

  • 0

First question from me; I’m currently fixing a graphing service that uses XSLFO to convert our syntax to FO, and converting it to PDF in the end.

Previously we’ve been using PNG graphs from the web in the PDF exports, but this creates really ugly results, so we’ve decided to go with SVG for PDF instead.

However, the SVG doesn’t seem to scale into the SVG canvas properly.

Here is the syntax before run into XSLFO:

<img src="someimage.svg">

And here is the XSLFO I’m using:

   <xsl:template match="img">
      <fo:block space-after="12pt">
          <fo:instream-foreign-object width="20cm" height="15cm" content-width="scale-to-fit" content-height="scale-to-fit" scaling="uniform" background-color="#cccccc">
          <svg:svg x="0" y="0" width="100" height="100" viewBox="0 0 100 100">
                <svg:image x="0" y="0" width="100" height="100">
                    <xsl:if test="@src">
                       <xsl:attribute name="xlink:href">
                          <xsl:choose>
                             <xsl:when test="starts-with(@src, 'http://')">
                                <xsl:value-of select="@src"/>
                             </xsl:when>
                             <xsl:when test="starts-with(@src, 'https://')">
                                <xsl:value-of select="@src"/>
                             </xsl:when>
                             <xsl:otherwise>
                                <xsl:value-of select="concat($baseurl, @src)"/>
                             </xsl:otherwise>
                          </xsl:choose>
                       </xsl:attribute>
                    </xsl:if>
                   </svg:image>
            </svg:svg>
         </fo:instream-foreign-object>
      </fo:block>
   </xsl:template>

The SVG does appear in the PDF, and it does seem contained within the canvas – but for whatever reason I cannot get it to scale properly. It’s just really, really huge, and the result being an extremely cropped version of the SVG.

I’m running out of suggestions here – is there anyone here that has experience with this?

PS: The image is created using the newest version of Batik, and the width and height is set properly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:27:11+00:00Added an answer on May 13, 2026 at 9:27 pm

    Actually, instream-foreign-object didn’t seem to be able to scale the SVG at all, not even with the proper canvas set. By setting the correct canvas on the SVG, fo:external-graphic did the trick 😉

    Thanks you guys for giving me your tips 🙂 Here is what worked:

        <fo:external-graphic content-width="25cm" content-height="16cm">
            <xsl:if test="@src">
                <xsl:attribute name="src">
                    <xsl:choose>
                        <xsl:when test="starts-with(@src, 'http://')">
                            <xsl:value-of select="concat('url(',@src,')')"/>
                        </xsl:when>
                        <xsl:when test="starts-with(@src, 'https://')">
                            <xsl:value-of select="concat('url(',@src,')')"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="concat('url(',$baseurl, @src,')') + ')'"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:attribute>
            </xsl:if>
        </fo:external-graphic>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First question from a long time user. I'm writing a Perl script that will
This question arose from the discussion in the comments of this answer . First,
First question here: it is a very short yet fundamental thing in Java that
Prior Information: (In case you are wondering where I am coming from) First Question:
This is my first question. My python script opens and reads from a present
this is my first question here. Writing some code, i receive this error from
First question. Be gentle. I'm working on software that tracks technicians' time spent working
Another question from an app programmer who's trying the first time to get together
This is a two part question from a WPF animation newbie. First, here is
my first question is, where do I put this custom extension so that it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.