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 Zhong Yi <yi...@yahoo.com> on 2003/11/12 07:23:05 UTC

SVG output special character

I am trying to create a SVG output from fo, but the
special charaters are not handled exactly as I
expected.
FOP added several white spaces after it. The fo is
very simple, just have one special character "'" in
it.
If you look at the SVG, it actually break one word
into two lines.

Anyone knows how to get around this?

Here is the fo
<?xml version="1.0" encoding="utf-8"?>

<!-- example for a simple fo file. At the beginning
the page layout is set. 
  Below fo:root there is always 
- a single fo:layout-master-set which defines one or
more page layouts
- an optional fo:declarations 
- and a sequence of one or more fo:page-sequences
containing the text and formatting instructions 
-->

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

  <fo:layout-master-set>
  <!-- fo:layout-master-set defines in its children
the page layout: 
       the pagination and layout specifications
      - page-masters: have the role of describing the
intended subdivisions 
                       of a page and the geometry of
these subdivisions 
                      In this case there is only a
simple-page-master which defines the 
                      layout for all pages of the text
  -->
    <!-- layout information -->
    <fo:simple-page-master master-name="simple"
                  page-height="29.7cm" 
                  page-width="21cm"
                  margin-top="1cm" 
                  margin-bottom="2cm" 
                  margin-left="2.5cm" 
                  margin-right="2.5cm">
      <fo:region-body margin-top="3cm"
margin-bottom="1.5cm"/>
      <fo:region-before extent="3cm"/>
      <fo:region-after extent="1.5cm"/>
    </fo:simple-page-master>
  </fo:layout-master-set>
  <!-- end: defines page layout -->


  <!-- start page-sequence
       here comes the text (contained in flow objects)
       the page-sequence can contain different
fo:flows 
       the attribute value of master-name refers to
the page layout
       which is to be used to layout the text
contained in this
       page-sequence-->
  <fo:page-sequence master-reference="simple">

      <!-- start fo:flow
           each flow is targeted 
           at one (and only one) of the following:
           xsl-region-body (usually: normal text)
           xsl-region-before (usually: header)
           xsl-region-after  (usually: footer)
           xsl-region-start  (usually: left margin) 
           xsl-region-end    (usually: right margin)
           ['usually' applies here to languages with
left-right and top-down 
            writing direction like English]
           in this case there is only one target:
xsl-region-body
        -->
    <fo:flow flow-name="xsl-region-body">

      <!-- each paragraph is encapsulated in a block
element
           the attributes of the block define
           font-family and size, line-heigth etc. -->



      <!-- this defines normal text -->
      <fo:block font-size="12pt" 
                font-family="sans-serif" 
                line-height="15pt"
                space-after.optimum="3pt"
                text-align="justify">
        <![CDATA[ Boy's]]>
      </fo:block>



    </fo:flow> <!-- closes the flow element-->
  </fo:page-sequence> <!-- closes the page-sequence
-->
</fo:root>

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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


RE: SVG output special character

Posted by George Yi <gy...@srds.com>.
I think this is a bug in PrettyPrinter in batik.
If you just dump the SVGDocument into an outputstream, everything is
fine.

George

-----Original Message-----
From: Andreas L. Delmelle [mailto:a_l.delmelle@pandora.be] 
Sent: Wednesday, November 12, 2003 9:18 AM
To: fop-user@xml.apache.org; a_l.delmelle@pandora.be
Subject: RE: SVG output special character

> -----Original Message-----
> From: Andreas L. Delmelle [mailto:a_l.delmelle@pandora.be]
>
> > -----Original Message-----
> > From: Zhong Yi [mailto:yidaomao@yahoo.com]
> >
> <snip/>
> > If you look at the SVG, it actually break one word
> > into two lines.
> >
>
> I also tested it using "Boy&apos;s" but the string gets broken up
anyway.
> (Why? No idea... maybe we should try this with a different parser?)

Just a bit of follow-up...

Possible location (remote guess) :

org.apache.fop.svg.SVGUtilities
Line 158: org.w3c.dom.Text text = doc.createTextNode( str );

Or, even more likely, somewhere just before the string gets here.

In any case, since a line-break shows up in a text editor, but none in
the
svg
...
--a UTF-16 / UTF-8 problem?

HexEdit shows a &#x000A; being added after the &apos; in the resulting
svg
(as well as a lot of spaces &#x0020; for the indent, which, if I'm
correct,
seems to point to two text nodes actually being created in the DOM...)

Then again, what is the particular difference between:
>
> <fo:block>
>   Boy<fo:inline>&apos;</fo:inline>s
> </fo:block>
>
and
<fo:block>
  Boy&apos;s
</fo:block>

Anyone?

Cheerz,

Andreas


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



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


RE: SVG output special character

Posted by "Andreas L. Delmelle" <a_...@pandora.be>.
> -----Original Message-----
> From: Andreas L. Delmelle [mailto:a_l.delmelle@pandora.be]
>
> > -----Original Message-----
> > From: Zhong Yi [mailto:yidaomao@yahoo.com]
> >
> <snip/>
> > If you look at the SVG, it actually break one word
> > into two lines.
> >
>
> I also tested it using "Boy&apos;s" but the string gets broken up anyway.
> (Why? No idea... maybe we should try this with a different parser?)

Just a bit of follow-up...

Possible location (remote guess) :

org.apache.fop.svg.SVGUtilities
Line 158: org.w3c.dom.Text text = doc.createTextNode( str );

Or, even more likely, somewhere just before the string gets here.

In any case, since a line-break shows up in a text editor, but none in the
svg
...
--a UTF-16 / UTF-8 problem?

HexEdit shows a &#x000A; being added after the &apos; in the resulting svg
(as well as a lot of spaces &#x0020; for the indent, which, if I'm correct,
seems to point to two text nodes actually being created in the DOM...)

Then again, what is the particular difference between:
>
> <fo:block>
>   Boy<fo:inline>&apos;</fo:inline>s
> </fo:block>
>
and
<fo:block>
  Boy&apos;s
</fo:block>

Anyone?

Cheerz,

Andreas


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


RE: SVG output special character

Posted by "Andreas L. Delmelle" <a_...@pandora.be>.
> -----Original Message-----
> From: Zhong Yi [mailto:yidaomao@yahoo.com]
>
<snip/>
> If you look at the SVG, it actually break one word
> into two lines.
>

Hi,

I also tested it using "Boy&apos;s" but the string gets broken up anyway.
(Why? No idea... maybe we should try this with a different parser?)

<snip/>
> Anyone knows how to get around this?

Seems like the only way to keep this from happening is adding <fo:inline>
around the &apos;, like:

<fo:block>
  Boy<fo:inline>&apos;</fo:inline>s
</fo:block>

However, I don't know if there's any reason in particular why you are using
a CDATA section, so perhaps this workaround is impossible for you.

In any case, I hope this helps!

Greetz,

Andreas


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