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 "Li, Hao" <li...@peacetech.com> on 2008/01/31 18:14:36 UTC

font-size in percentage error

Hi,

We encountered the problem of using percentage on font-size attribute.
The error is "getBaselength called without context". 

<fo:block>
    <fo:block font-style="normal" space-after="0.1cm"
space-before="0.1cm" font-size="80%" role="html:div" text-align="left">1
Original  hardcopy  to CO 2 Hardcopies to PO and (1) electronic copy to
CO and  PO</fo:block>
  <fo:block font-style="normal" space-after="0.1cm" space-before="0.1cm"
font-size="80%" role="html:div" text-align="left"></fo:block>
</fo:block>

We thought that it might be the parent <fo:block> has no font-size
defined, so we added it as below, but the same error occurred.
   <fo:block font-size="10pt"><fo:block ...
font-size="80%"...>...</fo:block></fo:block>

Two cases can bypass this error:
1. Changing the font-size attribute to a non-percentage (i.e. 10pt or
12px).
2. If the font-size attribute (%) was in an <fo:inline>.
  <fo:block><fo:block font-style="normal" space-after="0.1cm"
space-before="0.1cm"  font-size="10pt" role="html:div"
text-align="left">
  <fo:inline font-weight="bold" role="html:strong" font-size="80%">Type
of Report</fo:inline></fo:block> 
</fo:block>


We are not sure if this is a bug, or we are not using it correctly.

Please help. We really appreciate it.

Henry

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


Re: fo:table-cell width in percentage

Posted by Andreas Delmelle <an...@telenet.be>.
On 22 Jan 2009, at 18:39, Li, Hao wrote:

> Is width in percentage supported in fo:table-cell such as <fo:table- 
> cell width="30%".../> ?

As mentioned in my earlier reply: not yet implemented.

Regards

Andreas

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


fo:table-cell width in percentage

Posted by "Li, Hao" <li...@peacetech.com>.
Hi,

Is width in percentage supported in fo:table-cell such as <fo:table-cell width="30%".../> ?

I could not make it work. Only a number or (number + px) works for me. Am I missing something? I am using FOP version 0.95 and later.

thank you very much for your help,

Hao

Re: know number of pages in end pdf without actually making it

Posted by Andreas Delmelle <an...@telenet.be>.
On 22 Jan 2009, at 22:16, Chakravarty, Abhishek wrote:

> Is there a way to know the number of pages in the final pdf document
> generated from FOP without actually doing its generation?

Depends on what you mean by "generation". The FO content at least has  
to be parsed and processed partly (layout) before FOP can tell you how  
many pages there will be.
The actual rendering of the resulting document can be postponed,  
currently still by using the intermediate area tree XML (see: http://xmlgraphics.apache.org/fop/0.95/intermediate.html)


> The XML content being pulled in for the pdf generation is dynamic  
> and so
> the number of pages being generated at the end would change too  
> based on
> this. Was wondering if there was someway of grabbing the number of  
> pages
> being generated in a 2 pass sequence.
>
> As in
> 1st pass:  XML + XSL -> FO
> 2nd pass: FO -> PDF

In Java code, you could generate the FO (your first pass), and store  
it on disk. In the same pass, you could immediately also echo the  
result to FOP to render to the intermediate format (dispatching the  
SAX events to multiple ContentHandlers). In a second pass, you can  
then merge information from the area tree with the FO.

The same can be done via the command-line, but it would be a multi- 
pass looking like:

1. XML + XSLT -> FO
2. FO -> Area Tree
3a. FO + XSLT -> PDF, or
3b. Area Tree + XSLT -> PDF

Where in 3a (resp. 3b) the necessary information can be extracted from  
the Area Tree (resp. FO) by means of XSLT's document() function.

HTH!

Andreas

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


know number of pages in end pdf without actually making it

Posted by "Chakravarty, Abhishek" <Ab...@accidentfund.com>.
Is there a way to know the number of pages in the final pdf document
generated from FOP without actually doing its generation?

The XML content being pulled in for the pdf generation is dynamic and so
the number of pages being generated at the end would change too based on
this. Was wondering if there was someway of grabbing the number of pages
being generated in a 2 pass sequence.

As in
1st pass:  XML + XSL -> FO
2nd pass: FO -> PDF

Any help would be appreciated.

Regards
Abhishek
---------------------------------------------------------------------
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: table-cell width in percentage

Posted by Andreas Delmelle <an...@telenet.be>.
On 22 Jan 2009, at 19:04, Li, Hao wrote:

> Is width in percentage supported in fo:table-cell such as <fo:table- 
> cell width="30%".../> ?

AFAIK, this is not implemented (mainly because it is not defined  
clearly in the XSL-FO Rec what the expected behavior should be)

Also, FOP does not yet support table-layout="auto", and "fixed"  
implicitly means that all cells in the same column will have the same  
width for all rows.

If you need to set column-width, you can use the proportional-column- 
width() function to obtain the same effect (assuming that the  
percentage is computed based on the total available width)

<fo:table table-layout="fixed" inline-progression-dimension="100%">
   <fo:table-column column-width="proportional-column-width(1)" number- 
columns-repeated="3" />
   ...

will produce a table where each column is 33.33% of the total width.


Cheers

Andreas

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


table-cell width in percentage

Posted by "Li, Hao" <li...@peacetech.com>.
Hi,

Is width in percentage supported in fo:table-cell such as <fo:table-cell width="30%".../> ?

I could not make it work. Only a number or (number + px) works for me. Am I missing something? I am using FOP version 0.95 and trunk.

thank you very much for your help,

Hao

Re: font-size in percentage error

Posted by Andreas Delmelle <an...@telenet.be>.
On Feb 1, 2008, at 19:51, Li, Hao wrote:

Hi

> Percentage + em seems to be working. Do I need to submit an issue  
> report
> to bugzilla?  Thanks.

That would be very helpful. I'll look into it soon, but just in case  
I don't find an immediate solution, a bug-report would be good to  
have as a reminder.

Thanks,

Andreas

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


RE: font-size in percentage error

Posted by "Li, Hao" <li...@peacetech.com>.
Percentage + em seems to be working. Do I need to submit an issue report
to bugzilla?  Thanks.

-----Original Message-----
From: Andreas Delmelle [mailto:adelmelle@apache.org] 
Sent: Friday, February 01, 2008 12:53 PM
To: fop-users@xmlgraphics.apache.org
Subject: Re: font-size in percentage error

On Feb 1, 2008, at 18:36, Li, Hao wrote:

> You are right. The sample I posted actually works. I apologize not
> recognizing the real problem. It is tricky and only occurs in the
> combination of <fo:inline> of font-size="smaller"/"bigger" within
> <fo:block> of font-size in percentage:

OK, now I see it too.

I'll run it through the debugger, but already think I know what is  
going on. The property resolution mechanism tries to resolve to  
smaller/larger font-sizes too early. Percentages are resolved (mostly  
anyway) during the layout-stage, where FOP tries to already resolve  
the "smaller" keyword long before that.

I haven't tried yet, but using em's could also lead to trouble in  
combination with percentages, as in:

<fo:block>
   <fo:block font-size="80%">
     <fo:inline font-size="8em">


Will keep you posted.

Cheers

Andreas

---------------------------------------------------------------------
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: font-size in percentage error

Posted by Andreas Delmelle <ad...@apache.org>.
On Feb 1, 2008, at 18:36, Li, Hao wrote:

> You are right. The sample I posted actually works. I apologize not
> recognizing the real problem. It is tricky and only occurs in the
> combination of <fo:inline> of font-size="smaller"/"bigger" within
> <fo:block> of font-size in percentage:

OK, now I see it too.

I'll run it through the debugger, but already think I know what is  
going on. The property resolution mechanism tries to resolve to  
smaller/larger font-sizes too early. Percentages are resolved (mostly  
anyway) during the layout-stage, where FOP tries to already resolve  
the "smaller" keyword long before that.

I haven't tried yet, but using em's could also lead to trouble in  
combination with percentages, as in:

<fo:block>
   <fo:block font-size="80%">
     <fo:inline font-size="8em">


Will keep you posted.

Cheers

Andreas

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


RE: font-size in percentage error

Posted by "Li, Hao" <li...@peacetech.com>.
You are right. The sample I posted actually works. I apologize not
recognizing the real problem. It is tricky and only occurs in the
combination of <fo:inline> of font-size="smaller"/"bigger" within
<fo:block> of font-size in percentage:

<fo:block font-style="normal" space-after="0.1cm" space-before="0.1cm"
font-size="80%" role="html:div" text-align="left">The 15<fo:inline
baseline-shift="super" font-size="smaller"
role="html:sup">th</fo:inline>of each month. </fo:block>

Thank you very much,


-----Original Message-----
From: Andreas Delmelle [mailto:andreas.delmelle@telenet.be] 
Sent: Thursday, January 31, 2008 3:04 PM
To: fop-users@xmlgraphics.apache.org
Subject: Re: font-size in percentage error

On Jan 31, 2008, at 18:14, Li, Hao wrote:

Hi

> We encountered the problem of using percentage on font-size attribute.
> The error is "getBaselength called without context".
> <snip />
> Two cases can bypass this error:
> 1. Changing the font-size attribute to a non-percentage (i.e. 10pt or
> 12px).

Indeed, this will simply bypass the percentage-resolution, so the  
problem does not occur here.

> 2. If the font-size attribute (%) was in an <fo:inline>.
>   <fo:block><fo:block font-style="normal" space-after="0.1cm"
> space-before="0.1cm"  font-size="10pt" role="html:div"
> text-align="left">
>   <fo:inline font-weight="bold" role="html:strong" font- 
> size="80%">Type
> of Report</fo:inline></fo:block>
> </fo:block>
>
>
> We are not sure if this is a bug, or we are not using it correctly.

It definitely seemed like a bug to me, especially because you  
mentioned the case of nested blocks.

On the other hand, (good news?) I cannot reproduce your issue with  
the latest development version of FOP. Which version are you using?

If percentages are an issue, then maybe em's will do the trick for you:

<fo:block>
   <fo:block font-size="0.8em">

should produce the exact same effect.


HTH!


Cheers

Andreas

---------------------------------------------------------------------
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: font-size in percentage error

Posted by Andreas Delmelle <an...@telenet.be>.
On Jan 31, 2008, at 18:14, Li, Hao wrote:

Hi

> We encountered the problem of using percentage on font-size attribute.
> The error is "getBaselength called without context".
> <snip />
> Two cases can bypass this error:
> 1. Changing the font-size attribute to a non-percentage (i.e. 10pt or
> 12px).

Indeed, this will simply bypass the percentage-resolution, so the  
problem does not occur here.

> 2. If the font-size attribute (%) was in an <fo:inline>.
>   <fo:block><fo:block font-style="normal" space-after="0.1cm"
> space-before="0.1cm"  font-size="10pt" role="html:div"
> text-align="left">
>   <fo:inline font-weight="bold" role="html:strong" font- 
> size="80%">Type
> of Report</fo:inline></fo:block>
> </fo:block>
>
>
> We are not sure if this is a bug, or we are not using it correctly.

It definitely seemed like a bug to me, especially because you  
mentioned the case of nested blocks.

On the other hand, (good news?) I cannot reproduce your issue with  
the latest development version of FOP. Which version are you using?

If percentages are an issue, then maybe em's will do the trick for you:

<fo:block>
   <fo:block font-size="0.8em">

should produce the exact same effect.


HTH!


Cheers

Andreas

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


Re: font-size in percentage error

Posted by Andreas Delmelle <ad...@apache.org>.
(Off-topic: Apologies to the moderators. I keep forgetting to switch  
mail-accounts when posting to fop-users, to which I've recently  
subscribed with my Apache address... :/)

On Jan 31, 2008, at 18:14, Li, Hao wrote:

Hi


> We encountered the problem of using percentage on font-size attribute.
> The error is "getBaselength called without context".
> <snip />
> Two cases can bypass this error:
> 1. Changing the font-size attribute to a non-percentage (i.e. 10pt or
> 12px).
>

Indeed, this will simply bypass the percentage-resolution, so the  
problem does not occur here.


> 2. If the font-size attribute (%) was in an <fo:inline>.
>   <fo:block><fo:block font-style="normal" space-after="0.1cm"
> space-before="0.1cm"  font-size="10pt" role="html:div"
> text-align="left">
>   <fo:inline font-weight="bold" role="html:strong" font- 
> size="80%">Type
> of Report</fo:inline></fo:block>
> </fo:block>
>
>
> We are not sure if this is a bug, or we are not using it correctly.
>

It definitely seemed like a bug to me, especially because you  
mentioned the case of nested blocks.

On the other hand, (good news?) I cannot reproduce your issue with  
the latest development version of FOP. Which version are you using?

If percentages are an issue, then maybe em's will do the trick for you:

<fo:block>
   <fo:block font-size="0.8em">

should produce the exact same effect.


HTH!


Cheers

Andreas


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