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

  • SEARCH
  • Home
  • 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 8098757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:10:33+00:00 2026-06-05T22:10:33+00:00

I have some SVG files that I’d like to create a PDF with. For

  • 0

I have some SVG files that I’d like to create a PDF with. For simplicity lets assume each one represents one page in the PDF. There is a node in the SVG containing some text that I would like to exclude. How do I go about doing so? Here’s a sample SVG file and fo to include it as a page in the PDF.

Lets say there exists a file named /home/dave/images/some_image.svg containing this:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="470" height="363" xml:space="preserve">
  <g clip-path="url(#some-path)">
    <rect id="some-rect" fill="#FFFFFF" stroke="#666" height="363" width="470" opacity="1" x="0" y="0"/>
    <defs id="some-defs">
      <clipPath id="some-path" x="0" y="0" width="100%" height="100%">
        <rect height="363" x="0" y="0" width="470" fill="#fff"/>
      </clipPath>
    </defs>
    <g id="some-group">
      <path id="a-path"/>
      <g id="a-container">
        <text id="some-text" x="235" y="181">This text needs to go</text>
        <image x="-2000" y="-1500" width="4000" height="3000" xlink:href="http://www.somewebsite.com/image.jpg" id="some-img"/>
      </g>
    </g>
  </g>
</svg>

and now for a sample fo that uses it

<?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 master-name="page" margin="0pt"
                           page-height="363pt" page-width="470pt">
      <fo:region-body />
    </fo:simple-page-master>
  </fo:layout-master-set>

  <fo:page-sequence master-reference="page">
    <fo:flow flow-name="xsl-region-body">
      <fo:block>
        <fo:external-graphic 
            src='/home/dave/images/some_image.svg'/>
      </fo:block>
    </fo:flow>
  </fo:page-sequence>

</fo:root>

So this works fine for including the whole svg “as is”. How can I exclude the text node?

<text id="some-text" x="235" y="181">This text needs to go</text>

As for the real files I’m using they reference a font that I won’t need to include in the PDF and the text will be behind the image anyway thus not viewable.

  • 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-06-05T22:10:35+00:00Added an answer on June 5, 2026 at 10:10 pm

    Keeping <fo:external-graphic /> : XSLT pre-processing

    If you want or need to keep the <fo:external-graphic /> approach, then you should certainly pre-process your SVG using XSLT, as suggested by Wivani

    A copy-all template and a remove template should be enough, like:

    <xsl:template match="node()|@*">
      <xsl:copy>
         <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
    </xsl:template>
    
    <xsl:template match="text[@id='some-text']"/>
    

    You can keep your FO as-is, maybe changing the SVG path to the new, pre-processed SVG:

    <fo:external-graphic src='/home/dave/images/some_image_stripped.svg'/>
    

    For more specific info, see other SO questions like:

    • XSLT 1.0: copy everything except certain nodes according to value and variable
    • XSL: how to copy a tree, but removing some nodes?
    • How to copy everything as is and only remove a specific element

    Alternative using <fo:instream-foreign-object />

    If, on the other hand, you want to keep a one-step process, you can investigate at inlining you SVG in your XML-FO, using <fo:instream-foreign-object />.

    But this would likely require you to change your processing logic, creating the XML-FO by means of an XSL transformation from your SVG file. This could conflict with other requirements of yours.

    You can have a look at Displaying SVG using XSLFO for more info on this technique.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some text lines like that : vt_wildshade2^508^508 vt_ailleurs2^1188^1188 ... vt_high2^13652^13652 Is it
I'm working with jQuery to modify some svg files data on the fly... one
I have some code that retrieves a scripted svg image from a server via
I have a stand-alone svg file that displays without problems. It includes some inline
I have a GWT application that generates SVG files. I want to embed an
I am currently using zoom.js to zoom-in on some SVG shapes that I have
I plan to have some (a lot of) objects inside of svg-object that will
I have some objects inside of svg that can be clicked by user. Is
I know almost nothing about SVG files, but have to use one in order
I have a web application that converts SVG files into swf ones. In order

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.