You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Walter Bauer <wb...@coware.de> on 2006/03/22 07:58:01 UTC

Indefinite page-height

Andreas, Matthias,
I've digged a little more into the code and would like to share what  
I've done and tested and so far.

I've added at the end of  
PageSequenceLayoutManager.PageBreaker.finishPart:
if (getCurrentPage().getSimplePageMaster().getPageHeight().getEnum()  
== Constants.EN_INDEFINITE) {
		Rectangle2D rect = getCurrentPV().getViewArea();
		getCurrentPV().getViewArea().setRect(rect.getX(), rect.getY(),  
rect.getWidth(), rect.getHeight() - pbp.difference);
}

After some experiments to set the height/width in the Constructor of  
PageViewport, I think it's better to defer it and resolve it in  
EnumLength.getValue:

public int getValue() {
	if (enumProperty.getEnum() == Constants.EN_INDEFINITE)
		Integer.MAX_VALUE;
	else
		return 0;
}

getValue is called in RegionBody.getViewportRectangle for example and  
changing getValue covers these calls as well.

Problems:

Actually it doesn't work that way. Returning Integer.MAX_VALUE in  
EnumLength.getValue fails, resulting in a ridiculous long PDF page.  
The length is off by 10000000. Returning some "huge" number instead  
like 10000000 but not Integer.MAX_VALUE  works however. Don't know  
why, but I suspect that there is some Integer overflow somewhere.

I'm not sure if PageSequenceLayoutManager.PageBreaker.finishPart is  
the right place to change the page size so tried a different approach  
leaving PageSequenceLayoutManager.PageBreaker.finishPart unchanged.

Putting this code into PageSequenceLayoutManager.finishPage:
if (curPage.getSimplePageMaster().getPageHeight().getEnum() ==  
Constants.EN_INDEFINITE) {
		int height = (int) curPage.getPageViewport().getBodyRegion 
().getRegionViewport().getViewArea().getY();
		List spanList = curPage.getPageViewport().getBodyRegion 
().getMainReference().getSpans();
		ListIterator spanListIter = spanList.listIterator();
		while (spanListIter.hasNext()) {
				Span span = (Span) spanListIter.next();
				height += span.getHeight();
		}
		Rectangle2D rect = curPage.getPageViewport().getViewArea();
		curPage.getPageViewport().getViewArea().setRect(rect.getX(),  
rect.getY(), rect.getWidth(), height);
}

works neatly, even with Integer.MAX_VALUE. However I don't like this  
"manual" height recalculation too much.

Additional to dos / questions:

fo:region-body margin-bottom="1in" doesn't work yet
The after region has to be adjusted, otherwise it doesn't appear. How  
to do that?
Support of page-width="indefinite"

Best regards,
Walter



Re: Indefinite page-height

Posted by Andreas L Delmelle <a_...@pandora.be>.
On Mar 22, 2006, at 07:58, Walter Bauer wrote:

Hi Walter,

First of all: Thanks for diving into this!

Now,

> Problems:
>
> Actually it doesn't work that way. Returning Integer.MAX_VALUE in  
> EnumLength.getValue fails, resulting in a ridiculous long PDF page.  
> The length is off by 10000000. Returning some "huge" number instead  
> like 10000000 but not Integer.MAX_VALUE  works however. Don't know  
> why, but I suspect that there is some Integer overflow somewhere.
>
> I'm not sure if PageSequenceLayoutManager.PageBreaker.finishPart is  
> the right place to change the page size so tried a different  
> approach leaving PageSequenceLayoutManager.PageBreaker.finishPart  
> unchanged.
> <snip />
> works neatly, even with Integer.MAX_VALUE. However I don't like  
> this "manual" height recalculation too much.

That's precisely why we (actually Luca Furini) thought it belonged in  
finishPart(), since there you have the height of the content after  
layout without any hassle: you know that initially, the page-size  
will be Integer.MAX_VALUE. The accumulated content-height is, if I  
recall correctly, PageBreakPosition.difference...

> Additional to dos / questions:
>
> fo:region-body margin-bottom="1in" doesn't work yet
> The after region has to be adjusted, otherwise it doesn't appear.  
> How to do that?

Only the offset of the regionViewport in question needs to be altered
(decrease by Integer.MAX_VALUE - PBP.difference? Something like  
that...?)

Unfortunately, I don't have too much time right now. I'll look into  
it in more detail, probably some time during the weekend.

Later,

Andreas