Found it - the attached shows the bug. The center alignment is turned off if
you call:

      para.setKeepTogether( true );

- dave



----- Original Message -----
From: "Matt Benson" <[EMAIL PROTECTED]>
To: "David Thielen" <[EMAIL PROTECTED]>; "itext"
<[EMAIL PROTECTED]>
Sent: Friday, November 01, 2002 11:57 AM
Subject: Re: [iText-questions] Asking again: Element.ALIGN_CENTER doesn't
work


> What Paulo always says:
>
> "Post a small working example with the problem."
>
> I tried the general approach you described and it
> works for me:
>
> import java.io.FileOutputStream;
>
> import com.lowagie.text.Phrase;
> import com.lowagie.text.Document;
> import com.lowagie.text.Paragraph;
> import com.lowagie.text.pdf.PdfWriter;
>
> public class ParagraphAlignmentTest
> {
> public static void main(String[] args)
> throws Exception
> {
> int code = 0;
>
> Document doc = new Document();
>
> PdfWriter.getInstance(doc, new
> FileOutputStream("ParagraphAlignmentTest.pdf"));
>
> doc.open();
>
> Paragraph para = new Paragraph();
> para.setAlignment(Paragraph.ALIGN_CENTER);
> para.add(new Phrase("abc\n"));
> para.add(new Phrase("123\n"));
> para.add(new Phrase("xyz\n"));
> para.add(new Phrase("we the people of so and
> so\n"));
> para.add(new Phrase("in order to form a more perfect
> union\n"));
> para.add(new Phrase("hereby do something drastic and
> spastic and elastic and bombastic\n"));
> para.add(new Phrase("woo hoo"));
>
> doc.add(para);
>
> doc.close();
>
> System.exit(code);
> }//end main
> }//end class ParagraphAlignmentTest
>
>
> --- David Thielen <[EMAIL PROTECTED]> wrote:
> >
> >   ----- Original Message -----
> >   From: David Thielen
> >   To: itext
> >   Sent: Thursday, October 31, 2002 2:52 PM
> >   Subject: Element.ALIGN_CENTER doesn't work
> >
> >
> >   I set:
> >       pdfPara = new Paragraph();
> >       pdfPara.setAlignment( Element.ALIGN_CENTER );
> >       pdfPara.add( new Phrase( elem.getText(),
> >             new Font( font,
> >              ((float)charState.getFontSize()) /
> > 2.0f,
> >              style )));
> >       pdfPara.add( new Phrase( elem.getText(),
> >             new Font( font,
> >              ((float)charState.getFontSize()) /
> > 2.0f,
> >              style )));
> >       document.add( pdfPara );
> >
> >   and then added a bunch of phrases to a paragraph -
> > and it aligned left all of the para.
> >
> >   Any ideas?
> >
> >   thanks - dave
>
>
> __________________________________________________
> Do you Yahoo!?
> HotJobs - Search new jobs daily now
> http://hotjobs.yahoo.com/
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: See the NEW Palm
> Tungsten T handheld. Power & Color in a compact size!
> http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>

Attachment: Center.java
Description: JavaScript source

Reply via email to