You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Eliot Kimber <ek...@contrext.com> on 2018/08/15 20:21:07 UTC

Any Idea Why Word Does not Preserve Leading or Trailing Space?

In the DOCX I'm generating I have this pair of runs:

<w:r><w:t>If an applicant under subsection</w:t></w:r><w:r><w:t xml:space="preserve"> 38-79</w:t></w:r>

Notice the leading space in the second run (" 38-79").

When I view this with Word for Mac (16.16) the space is not rendered.

This seems like a bug, especially since space is preserve on the w:t element.

Any idea why Word behaves this way and if there's a way to avoid it (other than merging the two runs, which in this case have the same properties)?

This is DOCX being generated from XML source where the runs reflect separate source nodes (in this case a text node and then an inline element).

Thanks,

Eliot
--
Eliot Kimber
http://contrext.com
 



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


Re: Any Idea Why Word Does not Preserve Leading or Trailing Space?

Posted by Greg Woolsey <gr...@gmail.com>.
If you manually add the space in Word for Mac, where it isn't being
rendered when already present in the source, and save it, what does the
resulting XML look like?  Does Word then merge the runs, escape it somehow,
or something else?

On Thu, Aug 16, 2018 at 8:01 AM Eliot Kimber <ek...@contrext.com> wrote:

> I tried putting the space as the end of the preceding run and it also got
> removed, so either my test is bad or something else is going on.
>
> I can enhance my generation process to combine runs that have the same
> properties but that's annoying and adds processing time.
>
> Cheers,
>
> E.
>
> --
> Eliot Kimber
> http://contrext.com
>
>
> On 8/16/18, 8:46 AM, "Murphy, Mark" <mu...@metalexmfg.com> wrote:
>
>     Maybe the space is preserved only at the end of the text in the node?
>
>     -----Original Message-----
>     From: Eliot Kimber [mailto:ekimber@contrext.com]
>     Sent: Wednesday, August 15, 2018 4:21 PM
>     To: POI Users List <us...@poi.apache.org>
>     Subject: Any Idea Why Word Does not Preserve Leading or Trailing Space?
>
>     In the DOCX I'm generating I have this pair of runs:
>
>     <w:r><w:t>If an applicant under subsection</w:t></w:r><w:r><w:t
> xml:space="preserve"> 38-79</w:t></w:r>
>
>     Notice the leading space in the second run (" 38-79").
>
>     When I view this with Word for Mac (16.16) the space is not rendered.
>
>     This seems like a bug, especially since space is preserve on the w:t
> element.
>
>     Any idea why Word behaves this way and if there's a way to avoid it
> (other than merging the two runs, which in this case have the same
> properties)?
>
>     This is DOCX being generated from XML source where the runs reflect
> separate source nodes (in this case a text node and then an inline element).
>
>     Thanks,
>
>     Eliot
>     --
>     Eliot Kimber
>     http://contrext.com
>
>
>
>
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: user-unsubscribe@poi.apache.org For
> additional commands, e-mail: user-help@poi.apache.org
>
>
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>     For additional commands, e-mail: user-help@poi.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re: Any Idea Why Word Does not Preserve Leading or Trailing Space?

Posted by Eliot Kimber <ek...@contrext.com>.
I tried putting the space as the end of the preceding run and it also got removed, so either my test is bad or something else is going on.

I can enhance my generation process to combine runs that have the same properties but that's annoying and adds processing time.

Cheers,

E.

--
Eliot Kimber
http://contrext.com
 

On 8/16/18, 8:46 AM, "Murphy, Mark" <mu...@metalexmfg.com> wrote:

    Maybe the space is preserved only at the end of the text in the node?
    
    -----Original Message-----
    From: Eliot Kimber [mailto:ekimber@contrext.com] 
    Sent: Wednesday, August 15, 2018 4:21 PM
    To: POI Users List <us...@poi.apache.org>
    Subject: Any Idea Why Word Does not Preserve Leading or Trailing Space?
    
    In the DOCX I'm generating I have this pair of runs:
    
    <w:r><w:t>If an applicant under subsection</w:t></w:r><w:r><w:t xml:space="preserve"> 38-79</w:t></w:r>
    
    Notice the leading space in the second run (" 38-79").
    
    When I view this with Word for Mac (16.16) the space is not rendered.
    
    This seems like a bug, especially since space is preserve on the w:t element.
    
    Any idea why Word behaves this way and if there's a way to avoid it (other than merging the two runs, which in this case have the same properties)?
    
    This is DOCX being generated from XML source where the runs reflect separate source nodes (in this case a text node and then an inline element).
    
    Thanks,
    
    Eliot
    --
    Eliot Kimber
    http://contrext.com
     
    
    
    
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@poi.apache.org For additional commands, e-mail: user-help@poi.apache.org
    
    
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
    For additional commands, e-mail: user-help@poi.apache.org
    



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


RE: Any Idea Why Word Does not Preserve Leading or Trailing Space?

Posted by "Murphy, Mark" <mu...@metalexmfg.com>.
Maybe the space is preserved only at the end of the text in the node?

-----Original Message-----
From: Eliot Kimber [mailto:ekimber@contrext.com] 
Sent: Wednesday, August 15, 2018 4:21 PM
To: POI Users List <us...@poi.apache.org>
Subject: Any Idea Why Word Does not Preserve Leading or Trailing Space?

In the DOCX I'm generating I have this pair of runs:

<w:r><w:t>If an applicant under subsection</w:t></w:r><w:r><w:t xml:space="preserve"> 38-79</w:t></w:r>

Notice the leading space in the second run (" 38-79").

When I view this with Word for Mac (16.16) the space is not rendered.

This seems like a bug, especially since space is preserve on the w:t element.

Any idea why Word behaves this way and if there's a way to avoid it (other than merging the two runs, which in this case have the same properties)?

This is DOCX being generated from XML source where the runs reflect separate source nodes (in this case a text node and then an inline element).

Thanks,

Eliot
--
Eliot Kimber
http://contrext.com
 



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


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