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 Dirk Bromberg <br...@tzi.de> on 2005/12/10 13:52:48 UTC

Image in table not fitting full height?

Hi,

i've a problem with an image into a table.

Here is my fo sample. And a screenshot form the pdf.
 I want the image in the "xsl-region-before" to scale the full height of 
the cell (table) but there  is 1mm border above and 2 mm border below 
the image remaining. Are there default marigns paddings or borders at 
cells block or tables?

Please tell me how to make the "logo" fits image to the full table height.

I tryed with fop 20.5 / 0.90 a1 and renderx.... alle the same result...


Thanks

Dirk


<?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="only" page-height="29.7cm"
    page-width="21cm" margin-top="0cm" margin-bottom="0cm"
    margin-left="0cm" margin-right="0cm">
      <fo:region-body margin-top="3cm" margin-bottom="2.9cm"
      margin-left="2cm" margin-right="2cm" />
      <fo:region-before precedence="true" extent="2.9cm" />
      <fo:region-after precedence="true" extent="1.5cm" />
    </fo:simple-page-master>
  </fo:layout-master-set>
  <fo:page-sequence master-reference="only">
    <fo:static-content flow-name="xsl-region-before">
      <fo:table background-color="#38528D" table-layout="fixed"
      height="24mm">
        <fo:table-column column-width="145mm" />
        <fo:table-column column-width="45mm" />
        <fo:table-column column-width="20mm" />
        <fo:table-body>
          <fo:table-row>
            <fo:table-cell padding-right="5mm" text-align="left">
              <fo:block color="white" text-align="right"
              font-weight="bold"
              font-size="14pt" padding-top="9.0mm">Header
              1</fo:block>
              <fo:block color="white" text-align="right"
              font-weight="normal"
              font-size="11pt" padding-top="0mm">Header
              2</fo:block>
            </fo:table-cell>
            <fo:table-cell>
              <fo:block>
                <fo:external-graphic src="url(images/logo.jpg)"
                scaling="non-uniform" content-width="45mm"
                content-height="scale-to-fit" />
              </fo:block>
            </fo:table-cell>
            <fo:table-cell>
              <fo:block />
            </fo:table-cell>
          </fo:table-row>
        </fo:table-body>
      </fo:table>
    </fo:static-content>
    <fo:static-content flow-name="xsl-region-after">
      <fo:block>Footer Content</fo:block>
    </fo:static-content>
    <fo:flow flow-name="xsl-region-body">
      <fo:block>Page Content</fo:block>
    </fo:flow>
  </fo:page-sequence>
</fo:root>

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


Re: Image in table not fitting full height?

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
You're right, Manuel. I took this as an opportunity to reread the parts
in the spec about the line allocation rectangles. This also showed me
that line-stacking-strategy="line-height" would be the best way to go
here. Therefore, my former "ideal" example was wrong. It should have
been:

<fo:block background-color="yellow" line-stacking-strategy="line-height">
  <fo:external-graphic content-height="40pt" src="url('http://www.apache.org/images/asf_logo_wide.gif')"
    alignment-baseline="after-edge"/>
</fo:block>

But as you said, the "line-height" strategy isn't implemented, yet. But
at least, we've got a temporary work-around. :-)

Thanks, Manuel!

On 12.12.2005 13:01:04 Manuel Mall wrote:
> On Mon, 12 Dec 2005 12:07 am, Jeremias Maerki wrote:
> >
> > The gaps above and below of the images come from line-building, i.e.
> > from the line-height property among other factors. I was asked about
> > the same problem by the manufacturer of an FO editor. I still owe him
> > a reponse. :-( Anyway, I think we still have a bug in line-building.
> > I'll have to investigate a little further to come up with a test
> > case. But I think I found a work-around that works for now:
> >
> >       <fo:block background-color="yellow" font-size="0pt">
> >         <fo:external-graphic content-height="40pt"
> > src="url('http://www.apache.org/images/asf_logo_wide.gif')"/>
> > </fo:block>
> >
> > Setting font-size to 0pt does the trick because it doesn't create any
> > half-leading trait, or rather a "0mpt" value.
> >
> > In theory, the problem should be solved like this, I think:
> >
> >       <fo:block background-color="yellow" line-height="1.0">
> >         <fo:external-graphic content-height="40pt"
> > src="url('http://www.apache.org/images/asf_logo_wide.gif')"
> > alignment-baseline="after-edge"/> </fo:block>
> >
> > If I'm not mistaken, line-height="1.0" should in theory not lead to a
> > half-leading trait but that doesn't seem to happen right now. The
> > alignment-baseline is optional here as there are no characters in
> > this block that could have a descender because external-graphic is
> > normally aligned with the "baseline" AFAIK. But if there were
> > additional characters, this might be necessary depending on the
> > expectations. Maybe Manuel has some additional insight here. I'm not
> > the line-building specialist.
> >
> A line-height of 1 means line-height == font-size. The half-leading 
> trait is calculated according to XSL-FO as (line-height - text-altitude 
> + text-depth) / 2. For most fonts (and that applies to our default 
> fonts as well) text-altitude + text-depth < font-size. Therefore you do 
> get a non-zero half-leading value if line-height is 1. For our default 
> font at 12pt the half-leading value with line-height of 1 is 0.45pt. 
> That is enough to be visible in a PDF.
> 
> So I think we are not doing anything wrong.
> 
> There may be other workarounds (in theory) than the one Jeremias 
> suggested, like explicitly setting the text-altitude/depth properties, 
> or setting the line-stacking-strategy to line-height or setting some 
> conditionality on the line-height property. However, none of these are 
> currently implemented in fop. Therefore forcing the half-leading trait 
> to zero by setting the font-size to zero seems the way to go.


Jeremias Maerki


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


Re: Image in table not fitting full height?

Posted by Manuel Mall <mm...@arcus.com.au>.
On Mon, 12 Dec 2005 12:07 am, Jeremias Maerki wrote:
>
> The gaps above and below of the images come from line-building, i.e.
> from the line-height property among other factors. I was asked about
> the same problem by the manufacturer of an FO editor. I still owe him
> a reponse. :-( Anyway, I think we still have a bug in line-building.
> I'll have to investigate a little further to come up with a test
> case. But I think I found a work-around that works for now:
>
>       <fo:block background-color="yellow" font-size="0pt">
>         <fo:external-graphic content-height="40pt"
> src="url('http://www.apache.org/images/asf_logo_wide.gif')"/>
> </fo:block>
>
> Setting font-size to 0pt does the trick because it doesn't create any
> half-leading trait, or rather a "0mpt" value.
>
> In theory, the problem should be solved like this, I think:
>
>       <fo:block background-color="yellow" line-height="1.0">
>         <fo:external-graphic content-height="40pt"
> src="url('http://www.apache.org/images/asf_logo_wide.gif')"
> alignment-baseline="after-edge"/> </fo:block>
>
> If I'm not mistaken, line-height="1.0" should in theory not lead to a
> half-leading trait but that doesn't seem to happen right now. The
> alignment-baseline is optional here as there are no characters in
> this block that could have a descender because external-graphic is
> normally aligned with the "baseline" AFAIK. But if there were
> additional characters, this might be necessary depending on the
> expectations. Maybe Manuel has some additional insight here. I'm not
> the line-building specialist.
>
A line-height of 1 means line-height == font-size. The half-leading 
trait is calculated according to XSL-FO as (line-height - text-altitude 
+ text-depth) / 2. For most fonts (and that applies to our default 
fonts as well) text-altitude + text-depth < font-size. Therefore you do 
get a non-zero half-leading value if line-height is 1. For our default 
font at 12pt the half-leading value with line-height of 1 is 0.45pt. 
That is enough to be visible in a PDF.

So I think we are not doing anything wrong.

There may be other workarounds (in theory) than the one Jeremias 
suggested, like explicitly setting the text-altitude/depth properties, 
or setting the line-stacking-strategy to line-height or setting some 
conditionality on the line-height property. However, none of these are 
currently implemented in fop. Therefore forcing the half-leading trait 
to zero by setting the font-size to zero seems the way to go.

> HTH
>

Manuel

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


Re: Image in table not fitting full height?

Posted by Dirk Bromberg <br...@tzi.de>.
Thanks. the workaround with the font-size works great!

Dirk

Jeremias Maerki wrote:
> scaling-method is not evaluated by FOP, so it can't be the problem.
> Images are always embedded as is and scaled by the viewer/RIP. That
> means that the scaling is always target-device-specific.
>
> The gaps above and below of the images come from line-building, i.e.
> from the line-height property among other factors. I was asked about the
> same problem by the manufacturer of an FO editor. I still owe him a
> reponse. :-( Anyway, I think we still have a bug in line-building. I'll
> have to investigate a little further to come up with a test case. But I
> think I found a work-around that works for now:
>
>       <fo:block background-color="yellow" font-size="0pt">
>         <fo:external-graphic content-height="40pt" src="url('http://www.apache.org/images/asf_logo_wide.gif')"/>
>       </fo:block>
>
> Setting font-size to 0pt does the trick because it doesn't create any
> half-leading trait, or rather a "0mpt" value.
>
> In theory, the problem should be solved like this, I think:
>
>       <fo:block background-color="yellow" line-height="1.0">
>         <fo:external-graphic content-height="40pt" src="url('http://www.apache.org/images/asf_logo_wide.gif')" alignment-baseline="after-edge"/>
>       </fo:block>
>
> If I'm not mistaken, line-height="1.0" should in theory not lead to a
> half-leading trait but that doesn't seem to happen right now. The
> alignment-baseline is optional here as there are no characters in this
> block that could have a descender because external-graphic is normally
> aligned with the "baseline" AFAIK. But if there were additional
> characters, this might be necessary depending on the expectations. Maybe
> Manuel has some additional insight here. I'm not the line-building
> specialist.
>
> HTH
>
> On 10.12.2005 22:20:23 Andreas L Delmelle wrote:
>   
>> On Dec 10, 2005, at 13:52, Dirk Bromberg wrote:
>>
>>     
>>> Here is my fo sample. And a screenshot form the pdf.
>>> I want the image in the "xsl-region-before" to scale the full  
>>> height of the cell (table) but there  is 1mm border above and 2 mm  
>>> border below the image remaining. Are there default marigns  
>>> paddings or borders at cells block or tables?
>>>
>>> Please tell me how to make the "logo" fits image to the full table  
>>> height.
>>>       
>> The most likely cause seems to be "scaling-method". If that property  
>> set to "auto" (= initial value) then the formatter may choose the  
>> method. I'm guessing all three tested formatters default to "integer- 
>> pixels", which could cause rounding in determining the number of  
>> device pixels...
>>
>> As a workaround, maybe you could try making the table-cell's  
>> background-color black, which would at least create the desired  
>> appearance.
>>     
>
>
> Jeremias Maerki
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>   

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


Re: Image in table not fitting full height?

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
scaling-method is not evaluated by FOP, so it can't be the problem.
Images are always embedded as is and scaled by the viewer/RIP. That
means that the scaling is always target-device-specific.

The gaps above and below of the images come from line-building, i.e.
from the line-height property among other factors. I was asked about the
same problem by the manufacturer of an FO editor. I still owe him a
reponse. :-( Anyway, I think we still have a bug in line-building. I'll
have to investigate a little further to come up with a test case. But I
think I found a work-around that works for now:

      <fo:block background-color="yellow" font-size="0pt">
        <fo:external-graphic content-height="40pt" src="url('http://www.apache.org/images/asf_logo_wide.gif')"/>
      </fo:block>

Setting font-size to 0pt does the trick because it doesn't create any
half-leading trait, or rather a "0mpt" value.

In theory, the problem should be solved like this, I think:

      <fo:block background-color="yellow" line-height="1.0">
        <fo:external-graphic content-height="40pt" src="url('http://www.apache.org/images/asf_logo_wide.gif')" alignment-baseline="after-edge"/>
      </fo:block>

If I'm not mistaken, line-height="1.0" should in theory not lead to a
half-leading trait but that doesn't seem to happen right now. The
alignment-baseline is optional here as there are no characters in this
block that could have a descender because external-graphic is normally
aligned with the "baseline" AFAIK. But if there were additional
characters, this might be necessary depending on the expectations. Maybe
Manuel has some additional insight here. I'm not the line-building
specialist.

HTH

On 10.12.2005 22:20:23 Andreas L Delmelle wrote:
> On Dec 10, 2005, at 13:52, Dirk Bromberg wrote:
> 
> > Here is my fo sample. And a screenshot form the pdf.
> > I want the image in the "xsl-region-before" to scale the full  
> > height of the cell (table) but there  is 1mm border above and 2 mm  
> > border below the image remaining. Are there default marigns  
> > paddings or borders at cells block or tables?
> >
> > Please tell me how to make the "logo" fits image to the full table  
> > height.
> 
> The most likely cause seems to be "scaling-method". If that property  
> set to "auto" (= initial value) then the formatter may choose the  
> method. I'm guessing all three tested formatters default to "integer- 
> pixels", which could cause rounding in determining the number of  
> device pixels...
> 
> As a workaround, maybe you could try making the table-cell's  
> background-color black, which would at least create the desired  
> appearance.


Jeremias Maerki


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


Re: Image in table not fitting full height?

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Dec 10, 2005, at 13:52, Dirk Bromberg wrote:

> Here is my fo sample. And a screenshot form the pdf.
> I want the image in the "xsl-region-before" to scale the full  
> height of the cell (table) but there  is 1mm border above and 2 mm  
> border below the image remaining. Are there default marigns  
> paddings or borders at cells block or tables?
>
> Please tell me how to make the "logo" fits image to the full table  
> height.

The most likely cause seems to be "scaling-method". If that property  
set to "auto" (= initial value) then the formatter may choose the  
method. I'm guessing all three tested formatters default to "integer- 
pixels", which could cause rounding in determining the number of  
device pixels...

As a workaround, maybe you could try making the table-cell's  
background-color black, which would at least create the desired  
appearance.


Cheers,

Andreas


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


Re: Image in table not fitting full height?

Posted by Dirk Bromberg <br...@tzi.de>.
Here is the result PDF.

Thanks

Dirk


Dirk Bromberg wrote: <ci...@tzi.de>
> Hi,
>
> i've a problem with an image into a table.
>
> Here is my fo sample. And a screenshot form the pdf.
> I want the image in the "xsl-region-before" to scale the full height 
> of the cell (table) but there  is 1mm border above and 2 mm border 
> below the image remaining. Are there default marigns paddings or 
> borders at cells block or tables?
>
> Please tell me how to make the "logo" fits image to the full table 
> height.
>
> I tryed with fop 20.5 / 0.90 a1 and renderx.... alle the same result...
>
>
> Thanks
>
> Dirk
>
>
> <?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="only" page-height="29.7cm"
>    page-width="21cm" margin-top="0cm" margin-bottom="0cm"
>    margin-left="0cm" margin-right="0cm">
>      <fo:region-body margin-top="3cm" margin-bottom="2.9cm"
>      margin-left="2cm" margin-right="2cm" />
>      <fo:region-before precedence="true" extent="2.9cm" />
>      <fo:region-after precedence="true" extent="1.5cm" />
>    </fo:simple-page-master>
>  </fo:layout-master-set>
>  <fo:page-sequence master-reference="only">
>    <fo:static-content flow-name="xsl-region-before">
>      <fo:table background-color="#38528D" table-layout="fixed"
>      height="24mm">
>        <fo:table-column column-width="145mm" />
>        <fo:table-column column-width="45mm" />
>        <fo:table-column column-width="20mm" />
>        <fo:table-body>
>          <fo:table-row>
>            <fo:table-cell padding-right="5mm" text-align="left">
>              <fo:block color="white" text-align="right"
>              font-weight="bold"
>              font-size="14pt" padding-top="9.0mm">Header
>              1</fo:block>
>              <fo:block color="white" text-align="right"
>              font-weight="normal"
>              font-size="11pt" padding-top="0mm">Header
>              2</fo:block>
>            </fo:table-cell>
>            <fo:table-cell>
>              <fo:block>
>                <fo:external-graphic src="url(images/logo.jpg)"
>                scaling="non-uniform" content-width="45mm"
>                content-height="scale-to-fit" />
>              </fo:block>
>            </fo:table-cell>
>            <fo:table-cell>
>              <fo:block />
>            </fo:table-cell>
>          </fo:table-row>
>        </fo:table-body>
>      </fo:table>
>    </fo:static-content>
>    <fo:static-content flow-name="xsl-region-after">
>      <fo:block>Footer Content</fo:block>
>    </fo:static-content>
>    <fo:flow flow-name="xsl-region-body">
>      <fo:block>Page Content</fo:block>
>    </fo:flow>
>  </fo:page-sequence>
> </fo:root>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org