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

Reply via email to