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 lu...@saros.fr on 2002/03/06 09:12:46 UTC

display numbers

Hi,
I have to display numbers in a PDF document, but it's frequently thousands or 
millions, so I would like to render it like this:
1 000 000 or 1'000'000
instead of 1000000
is it possible or may I write a fonction that convert it in a string before 
rendering it??
Moreover, is the choice of the language including the rendering of numbers?? 
for exemple in France we use a coma and not a dot in numbers:
14,89 <=> 14.89

cheers,
Ludo.
 

-------------------------------------------------
    Webmail Saros: http://webmail.saros.fr


Re: display numbers

Posted by lu...@saros.fr.
Merci Guillaume,

I didn't know this class, it will be very helpful. 
thanks a lot,

Ludo.


Surlignage Guillaume Laforge <gl...@reflexe.fr>:

> Salut Ludo !
> 
> If you wish to format a number, depending on a specified locale, you can
> convert your Float with some classes found in the java.text package. You can
> specify a pattern for the resulting String.
> 
> DecimalFormat nf = (DecimalFormat)DecimalFormat.getInstance(Locale.FRENCH);
> nf.applyPattern("#,##0.00"); 
> // this pattern is very usefull for just keeping two digit for the decimal
> part (especially when dealing with currencies
> Float myFloatNumber = 123456789.123456
> String myFormattedString = nf.format(myFloatNumber);
> // myFormattedString will be equal to "123 456 789,12" in the locale is
> French
> // and it will be equal to "123,456,789.12" if the locale is English
> 
> Guillaume
>   ----- Original Message ----- 
>   From: ludovic.maurillon@saros.fr 
>   To: fop-user@xml.apache.org 
>   Sent: Wednesday, March 06, 2002 9:12 AM
>   Subject: display numbers
> 
> 
>   Hi,
>   I have to display numbers in a PDF document, but it's frequently thousands
> or 
>   millions, so I would like to render it like this:
>   1 000 000 or 1'000'000
>   instead of 1000000
>   is it possible or may I write a fonction that convert it in a string before
> 
>   rendering it??
>   Moreover, is the choice of the language including the rendering of
> numbers?? 
>   for exemple in France we use a coma and not a dot in numbers:
>   14,89 <=> 14.89
> 
>   cheers,
>   Ludo.
>    
> 
>   -------------------------------------------------
>       Webmail Saros: http://webmail.saros.fr
> 
> 
> 




-------------------------------------------------
    Webmail Saros: http://webmail.saros.fr


Re: display numbers

Posted by Guillaume Laforge <gl...@reflexe.fr>.
Salut Ludo !

If you wish to format a number, depending on a specified locale, you can convert your Float with some classes found in the java.text package. You can specify a pattern for the resulting String.

DecimalFormat nf = (DecimalFormat)DecimalFormat.getInstance(Locale.FRENCH);
nf.applyPattern("#,##0.00"); 
// this pattern is very usefull for just keeping two digit for the decimal part (especially when dealing with currencies
Float myFloatNumber = 123456789.123456
String myFormattedString = nf.format(myFloatNumber);
// myFormattedString will be equal to "123 456 789,12" in the locale is French
// and it will be equal to "123,456,789.12" if the locale is English

Guillaume
  ----- Original Message ----- 
  From: ludovic.maurillon@saros.fr 
  To: fop-user@xml.apache.org 
  Sent: Wednesday, March 06, 2002 9:12 AM
  Subject: display numbers


  Hi,
  I have to display numbers in a PDF document, but it's frequently thousands or 
  millions, so I would like to render it like this:
  1 000 000 or 1'000'000
  instead of 1000000
  is it possible or may I write a fonction that convert it in a string before 
  rendering it??
  Moreover, is the choice of the language including the rendering of numbers?? 
  for exemple in France we use a coma and not a dot in numbers:
  14,89 <=> 14.89

  cheers,
  Ludo.
   

  -------------------------------------------------
      Webmail Saros: http://webmail.saros.fr



Re: display numbers

Posted by "Christopher R. Maden" <cr...@maden.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 00:12 6-03-2002, ludovic.maurillon@saros.fr wrote:
>I have to display numbers in a PDF document, but it's frequently thousands or
>millions, so I would like to render it like this:
>1 000 000 or 1'000'000
>instead of 1000000
>is it possible or may I write a fonction that convert it in a string before
>rendering it??

FOP doesn't deal with numbers at all, only characters.  If you pass it "1 
000 000" it will format "1 000 000".  [There are a few exceptions, as for 
page numbers.]

If you are using XSLT to create your FOs which are passed to FOP, then look 
at the xsl:number element and its attributes.

~Chris
- -- 
Christopher R. Maden, Principal Consultant, crism consulting
DTDs/schemas - conversion - ebooks - publishing - Web - B2B - training
<URL: http://crism.maden.org/consulting/ >
PGP Fingerprint: BBA6 4085 DED0 E176 D6D4  5DFC AC52 F825 AFEC 58DA
-----BEGIN PGP SIGNATURE-----
Version: PGP Personal Privacy 6.5.8

iQA/AwUBPIXjL6xS+CWv7FjaEQLk4gCfTcdAOxOEv4QMIr8FtfaudRqTo/oAoKF7
wIaCQTyy5Lj58+SSKfd3i7n7
=wYGW
-----END PGP SIGNATURE-----


RE: display numbers

Posted by Peter Jacobs <li...@mediamagie.com>.
You can have a look at:

http://www.dpawson.co.uk/xsl/xslfaq.html
choose "XSLT Questions and Answers" and then "Formatting"

Please also have a look at the XSL FO pages, so this thread is not off topic
anymore :-)

HTH
Peter

------------------------
Peter Jacobs
Freelance multimedia programmeur
De Budetstraat 8
B-3201 Aarschot
peter.jacobs@advalvas.be
016/573257


> -----Original Message-----
> From: ludovic.maurillon@saros.fr [mailto:ludovic.maurillon@saros.fr]
> Sent: woensdag 6 maart 2002 09:13
> To: fop-user@xml.apache.org
> Subject: display numbers
>
>
> Hi,
> I have to display numbers in a PDF document, but it's frequently
> thousands or
> millions, so I would like to render it like this:
> 1 000 000 or 1'000'000
> instead of 1000000
> is it possible or may I write a fonction that convert it in a
> string before
> rendering it??
> Moreover, is the choice of the language including the rendering
> of numbers??
> for exemple in France we use a coma and not a dot in numbers:
> 14,89 <=> 14.89
>
> cheers,
> Ludo.
>
>
> -------------------------------------------------
>     Webmail Saros: http://webmail.saros.fr
>