wouldn't something simple like:

Paragraph p = new Paragraph("Yours Sincerely \n Douglas Adams \n
Creative Consultant", ARIAL);
p.setKeepTogether(true);
document.add(p);

do the trick?

jeff

> -----Original Message-----
> From: 1T3XT info [mailto:[email protected]] 
> Sent: Wednesday, February 11, 2009 3:19 AM
> To: Post all your questions about iText here
> Subject: Re: [iText-questions] How to avoidAvoid Page break 
> in Paragraph
> 
> Pari Gandhi . wrote:
> > Hi,
> > 
> > I have written a program to create a PDF document using 
> iText.  See below:
> > 
> > Document document = new Document();      
> > ..... snip......
> > 
> > document.add(new Paragraph(dynamic_text,ARIAL));
> > 
> > document.add(new Paragraph("Yours Sincerely \n Douglas Adams \n 
> > Creative Consultant",ARIAL));
> > 
> > ..... snip......
> > 
> > I have a requirement that the text "Yours Sincerely \n 
> Douglas Adams 
> > \n Creative Consultant" should appear together (i.e., not 
> separated by 
> > a page break in between). In other words, if the content of 
> the page 
> > is too big so that the "Yours Sincerely \n Douglas Adams \n 
> Creative 
> > Consultant" does not fit in the same page, then it should appear in 
> > the next page.
> > 
> > How can I achieve this?
> 
> The best way to achieve this, is by using ColumnText.
> This is described in chapter 7 of the book.
> 
> There's a method getVerticalPosition (PdfWriter) that can 
> give you the current Y coordinate; once you know that 
> coordinate, you can use ColumnText in "simulation mode" to 
> check if specific content fits the page.
> --
> This answer is provided by 1T3XT BVBA
> http://www.1t3xt.com/ - http://www.1t3xt.info
> 
> --------------------------------------------------------------
> ----------------
> Create and Deploy Rich Internet Apps outside the browser with 
> Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can 
> use existing skills and code to build responsive, highly 
> engaging applications that combine the power of local 
> resources and data with the reach of the web. Download the 
> Adobe AIR SDK and Ajax docs to start building applications 
> today-http://p.sf.net/sfu/adobe-com
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> 
########################################################################
"This email message, including any attachments, is for the sole use of the 
intended recipients and may contain confidential and privileged information.  
Unauthorized use, disclosure or distribution of this email is strictly 
forbidden.  If you have received this message in error, please reply to the 
above sender notifying them of this error, and then kindly delete the message."
########################################################################

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to