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 Samuel Penn <sa...@glendale.org.uk> on 2011/12/14 19:52:16 UTC

More on external graphics

A while back, I posted about a problem I had with the positioning of
graphics within a document. I didn't get any solutions, and now I've
had some time to look at this again.

To recap: What I'm seeing is that on the second and subsequent pages
of a document, images placed using <fo:external-graphic/> appear above
the place they should, on top of the text preceeding the correct place
in the flow. Attached is a PDF demonstrating this effect.

I've cut the .fo file down as much as I can to demonstrate the effect
(the original document has alternating left/right headings and has a
two-column layout). I can also fix the problem by removing the
alternating pages - there's a commented out <fo:simple-master-page/>
in the file which if used displays the images correctly. Unfortunately,
I need alternating pages so this isn't a real option for me.

I've attached the .fo and a test image which demonstrates the problem.

I'm using fop-1.0.0 (on Ubuntu), though discovered the problem on 0.95.
The strange thing is, I'm sure I didn't have the problem on a previous
installation of 0.95 (though it's possible I didn't notice).

If anyone has any ideas on what the problem is, and how to solve it,
then I'd be very grateful.

-- 
Be seeing you,        Games: http://www.glendale.org.uk/
Sam.                  Posts: http://www.google.com/profiles/samuel.penn

Re: More on external graphics

Posted by Vincent Hennebert <vh...@gmail.com>.
Hi Samuel,

You have already figured out how to avoid the problem, but FYI, what you
are witnessing is the result of a bug in the code that handles pages of
different widths (the infamous Changing IPD feature). That bug appears
to have been fixed in Trunk but I don’t remember when.

Unless you have a good reason for wanting pages of different widths
I advise you to make sure that the widths of the region-body on all your
pages match. That is, make sure that the following operation:
      page-width
      − margin-left and margin-right on the simple-page-master
      − margin-left and margin-right on the region-body
gives the same result for all your pages.

HTH,
Vincent


On 16/12/11 10:53, Samuel Penn wrote:
> On Friday 16 December 2011 10:17:32 Pascal Sancho wrote:
>> Hi Samuel,
>>
>> I don't understand what you mean by "if I take 1mm off the left margin
>> on right hand pages..."
>> Can you provide a short snippet to illustrate, please?
> 
> Take the following definitions for left and right pages (these can be
> plugged into the test.fo that Luis posted):
> 
>     <fo:simple-page-master master-name="leftPage" page-height="297mm" page-
> width="210mm" margin-top="15mm" margin-bottom="15mm" margin-left="15mm" 
> margin-right="30mm">
>         <fo:region-body margin-left="20mm" margin-right="21mm"/>
>         <fo:region-before extent="15mm" region-name="region-before-left"/>
>         <fo:region-after extent="10mm" region-name="region-after-left"/>
>         <fo:region-start extent="20mm"/>
>         <fo:region-end extent="10mm"/>
>     </fo:simple-page-master>
> 
>     <fo:simple-page-master master-name="rightPage" page-height="297mm" page-
> width="210mm" margin-top="15mm" margin-bottom="15mm" margin-left="30mm" 
> margin-right="15mm">
>         <fo:region-body margin-left="21mm" margin-right="20mm"/>
>         <fo:region-before extent="16mm" region-name="region-before-right"/>
>         <fo:region-after extent="10mm" region-name="region-after-right"/>
>         <fo:region-start extent="20mm"/>
>         <fo:region-end extent="10mm"/>
>     </fo:simple-page-master>
> 
> 
> Both are balanced, in that the margin-right/margin-left for both
> the simple-page-master and region-body mirror each other for the
> left and right pages. In this case, images are placed correctly.
> 
> Concentrating on the following lines:
> 
> left:  <fo:region-body margin-left="20mm" margin-right="21mm"/>
> right: <fo:region-body margin-left="21mm" margin-right="20mm"/>
> 
> 
> If I change the margin-right for the left page to be 22mm, then the
> images are incorrectly placed on 2nd and subsequent pages (the problem
> that I was seeing).
> 
> If I also update the margin-left for the right page to be 22mm
> however, then images are correctly placed again.
> 
> There seems to be a similar constraint for the simple-page-master
> margins, in that left page needs to mirror right page. Changing
> the margins on one page (but not the other) breaks the images again.
> 
> 
> Am I making sense?
> 

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


Re: More on external graphics

Posted by Samuel Penn <sa...@glendale.org.uk>.
On Friday 16 December 2011 10:17:32 Pascal Sancho wrote:
> Hi Samuel,
> 
> I don't understand what you mean by "if I take 1mm off the left margin
> on right hand pages..."
> Can you provide a short snippet to illustrate, please?

Take the following definitions for left and right pages (these can be
plugged into the test.fo that Luis posted):

    <fo:simple-page-master master-name="leftPage" page-height="297mm" page-
width="210mm" margin-top="15mm" margin-bottom="15mm" margin-left="15mm" 
margin-right="30mm">
        <fo:region-body margin-left="20mm" margin-right="21mm"/>
        <fo:region-before extent="15mm" region-name="region-before-left"/>
        <fo:region-after extent="10mm" region-name="region-after-left"/>
        <fo:region-start extent="20mm"/>
        <fo:region-end extent="10mm"/>
    </fo:simple-page-master>

    <fo:simple-page-master master-name="rightPage" page-height="297mm" page-
width="210mm" margin-top="15mm" margin-bottom="15mm" margin-left="30mm" 
margin-right="15mm">
        <fo:region-body margin-left="21mm" margin-right="20mm"/>
        <fo:region-before extent="16mm" region-name="region-before-right"/>
        <fo:region-after extent="10mm" region-name="region-after-right"/>
        <fo:region-start extent="20mm"/>
        <fo:region-end extent="10mm"/>
    </fo:simple-page-master>


Both are balanced, in that the margin-right/margin-left for both
the simple-page-master and region-body mirror each other for the
left and right pages. In this case, images are placed correctly.

Concentrating on the following lines:

left:  <fo:region-body margin-left="20mm" margin-right="21mm"/>
right: <fo:region-body margin-left="21mm" margin-right="20mm"/>


If I change the margin-right for the left page to be 22mm, then the
images are incorrectly placed on 2nd and subsequent pages (the problem
that I was seeing).

If I also update the margin-left for the right page to be 22mm
however, then images are correctly placed again.

There seems to be a similar constraint for the simple-page-master
margins, in that left page needs to mirror right page. Changing
the margins on one page (but not the other) breaks the images again.


Am I making sense?

-- 
Be seeing you,        Games: http://www.glendale.org.uk/
Sam.                  Posts: http://www.google.com/profiles/samuel.penn

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


Re: More on external graphics

Posted by Pascal Sancho <pa...@takoma.fr>.
Hi Samuel,

I don't understand what you mean by "if I take 1mm off the left margin
on right hand pages..."
Can you provide a short snippet to illustrate, please?

I know there is a bug in inline-progression-dimension computation when
using 'mm' or 'cm' as unit, that can cause trouble when using inverted
left/right margins, witch is the case with your XSL-FO (see [1]).

[1] https://issues.apache.org/bugzilla/show_bug.cgi?id=51043

Le 16/12/2011 10:13, Samuel Penn a écrit :
> On Thursday 15 December 2011 23:50:54 Luis Bernardo wrote:
>> On 12/15/11 7:44 PM, Samuel Penn wrote:
>>> For some reason, if I tweak the margins a bit, then the image problem
>>> comes back. I did remove the negative margins whilst testing the
>>> example I sent, and it made no difference, so it seems not to be -ve
>>> margins as such, but it is something to do with those margins.
>>
>> Attached is an example with the side regions in place. The output is the
>> same as before.
> 
> Thanks. I actually just took the margins you defined and inserted them
> into my stylesheets, and it all worked. I almost have things how I want
> them, I just need to do some print tests to make sure it looks okay.
> 
> However, it seems to be that if the left/right page margins don't match, 
> then I get the problem with misplaced images. e.g., if I take 1mm off the
> left margin on right hand pages, I need to also take 1mm off the right
> margin on left hand pages in order for images to be placed correctly.
> 
> Not sure if this is expected behaviour, but it seems like a bug.
> 


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


Re: More on external graphics

Posted by Samuel Penn <sa...@glendale.org.uk>.
On Thursday 15 December 2011 23:50:54 Luis Bernardo wrote:
> On 12/15/11 7:44 PM, Samuel Penn wrote:
> > For some reason, if I tweak the margins a bit, then the image problem
> > comes back. I did remove the negative margins whilst testing the
> > example I sent, and it made no difference, so it seems not to be -ve
> > margins as such, but it is something to do with those margins.
> 
> Attached is an example with the side regions in place. The output is the
> same as before.

Thanks. I actually just took the margins you defined and inserted them
into my stylesheets, and it all worked. I almost have things how I want
them, I just need to do some print tests to make sure it looks okay.

However, it seems to be that if the left/right page margins don't match, 
then I get the problem with misplaced images. e.g., if I take 1mm off the
left margin on right hand pages, I need to also take 1mm off the right
margin on left hand pages in order for images to be placed correctly.

Not sure if this is expected behaviour, but it seems like a bug.

-- 
Be seeing you,        Games: http://www.glendale.org.uk/
Sam.                  Posts: http://www.google.com/profiles/samuel.penn

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


Re: More on external graphics

Posted by Pascal Sancho <pa...@takoma.fr>.
Sorry, this was addressed to Samuel

Le 16/12/2011 09:50, Pascal Sancho a écrit :
> Hi Luis,

-- 
Pascal

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


Re: More on external graphics

Posted by Pascal Sancho <pa...@takoma.fr>.
Hi Luis,
I tried your initial FO (with negative margin) against FOP 1.0 and FOP
trunk:
FOP 1.0 is buggy while FOP trunk works as expected.

In addition, note that with fo:external-object or
fo:instream-foreign-object, there are half-leading before and after,
that depend on font-size and line-height.
So, if your fo:block contains no text, you can set its font-height to 0.

If line-height has a ration value (witch is inherited and defaults to
1.2), you do not need to explicitely set it to 0

Le 16/12/2011 00:50, Luis Bernardo a écrit :
> On 12/15/11 7:44 PM, Samuel Penn wrote:
>> On Thursday 15 December 2011 00:26:43 Luis Bernardo wrote:
>>> Your page definitions (margins, paddings, and so on) may be part of the
>>> problem. Negative margins in a page are suspicious to me...
>> I probably had a reason for that, but I did that 10 years ago, so I
>> don't remember why.
> Maybe to get around a bug... but you should not need to do so now. But 
> it is important to understand the page regions and how margins relate to 
> extents.
>>> I fixed your example by reducing it a simpler case. If you are not using
>>> using the start, end, before and after regions you do not need to define
>>> them. Probably later you will want to use them for static content but
>>> for the purposes of your example they are not needed.
>> I do need all those regions in the real document. I've added your
>> margins into my actual stylesheet, and the graphics are fixed, however
>> the page dimensions are now too squashed.
>>
>> For some reason, if I tweak the margins a bit, then the image problem
>> comes back. I did remove the negative margins whilst testing the
>> example I sent, and it made no difference, so it seems not to be -ve
>> margins as such, but it is something to do with those margins.
> Attached is an example with the side regions in place. The output is the 
> same as before.
>> At least this gives me something to play with, and I can try tweaking
>> the values (and refresh my memory of what they all mean) to try and
>> find out exactly what values cause the issue.
>>
>> Thanks very much for your help.
>>
> 

-- 
Pascal

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


Re: More on external graphics

Posted by Luis Bernardo <lm...@gmail.com>.
On 12/15/11 7:44 PM, Samuel Penn wrote:
> On Thursday 15 December 2011 00:26:43 Luis Bernardo wrote:
>> Your page definitions (margins, paddings, and so on) may be part of the
>> problem. Negative margins in a page are suspicious to me...
> I probably had a reason for that, but I did that 10 years ago, so I
> don't remember why.
Maybe to get around a bug... but you should not need to do so now. But 
it is important to understand the page regions and how margins relate to 
extents.
>> I fixed your example by reducing it a simpler case. If you are not using
>> using the start, end, before and after regions you do not need to define
>> them. Probably later you will want to use them for static content but
>> for the purposes of your example they are not needed.
> I do need all those regions in the real document. I've added your
> margins into my actual stylesheet, and the graphics are fixed, however
> the page dimensions are now too squashed.
>
> For some reason, if I tweak the margins a bit, then the image problem
> comes back. I did remove the negative margins whilst testing the
> example I sent, and it made no difference, so it seems not to be -ve
> margins as such, but it is something to do with those margins.
Attached is an example with the side regions in place. The output is the 
same as before.
> At least this gives me something to play with, and I can try tweaking
> the values (and refresh my memory of what they all mean) to try and
> find out exactly what values cause the issue.
>
> Thanks very much for your help.
>


Re: More on external graphics

Posted by Samuel Penn <sa...@glendale.org.uk>.
On Thursday 15 December 2011 00:26:43 Luis Bernardo wrote:
> Your page definitions (margins, paddings, and so on) may be part of the
> problem. Negative margins in a page are suspicious to me...

I probably had a reason for that, but I did that 10 years ago, so I
don't remember why.

> I fixed your example by reducing it a simpler case. If you are not using
> using the start, end, before and after regions you do not need to define
> them. Probably later you will want to use them for static content but
> for the purposes of your example they are not needed.

I do need all those regions in the real document. I've added your
margins into my actual stylesheet, and the graphics are fixed, however
the page dimensions are now too squashed.

For some reason, if I tweak the margins a bit, then the image problem
comes back. I did remove the negative margins whilst testing the
example I sent, and it made no difference, so it seems not to be -ve
margins as such, but it is something to do with those margins.

At least this gives me something to play with, and I can try tweaking
the values (and refresh my memory of what they all mean) to try and
find out exactly what values cause the issue.

Thanks very much for your help.

-- 
Be seeing you,        Games: http://www.glendale.org.uk/
Sam.                  Posts: http://www.google.com/profiles/samuel.penn

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


Re: More on external graphics

Posted by Luis Bernardo <lm...@gmail.com>.
Your page definitions (margins, paddings, and so on) may be part of the 
problem. Negative margins in a page are suspicious to me...

I fixed your example by reducing it a simpler case. If you are not using 
using the start, end, before and after regions you do not need to define 
them. Probably later you will want to use them for static content but 
for the purposes of your example they are not needed.

Source and output attached.

Luis

On 12/14/11 6:52 PM, Samuel Penn wrote:
> A while back, I posted about a problem I had with the positioning of
> graphics within a document. I didn't get any solutions, and now I've
> had some time to look at this again.
>
> To recap: What I'm seeing is that on the second and subsequent pages
> of a document, images placed using<fo:external-graphic/>  appear above
> the place they should, on top of the text preceeding the correct place
> in the flow. Attached is a PDF demonstrating this effect.
>
> I've cut the .fo file down as much as I can to demonstrate the effect
> (the original document has alternating left/right headings and has a
> two-column layout). I can also fix the problem by removing the
> alternating pages - there's a commented out<fo:simple-master-page/>
> in the file which if used displays the images correctly. Unfortunately,
> I need alternating pages so this isn't a real option for me.
>
> I've attached the .fo and a test image which demonstrates the problem.
>
> I'm using fop-1.0.0 (on Ubuntu), though discovered the problem on 0.95.
> The strange thing is, I'm sure I didn't have the problem on a previous
> installation of 0.95 (though it's possible I didn't notice).
>
> If anyone has any ideas on what the problem is, and how to solve it,
> then I'd be very grateful.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org