2

I have a table with cells set up like this:

Paragraph p = new Paragraph(content,font); 
p.setLeading(30); 
PdfPCell c = new PdfPCell(p);

My problem is that the paragraph leading is ignored. Can someone please tell me how to set the paragraph leading when inside a table cell? It works perfectly when not inside a cell.

Thanks.

Reda
  • 1,277
  • 1
  • 13
  • 27
  • possible duplicate of [Adding more text to a cell in table in itext](http://stackoverflow.com/questions/25325408/adding-more-text-to-a-cell-in-table-in-itext) – Alexis Pigeon Sep 15 '14 at 15:01
  • @AlexisPigeon i don't think it's a duplicate, the problem here is the leading is not visible. – Reda Sep 15 '14 at 15:05
  • The question by itself is not a duplicate, but the root cause of the issue (text vs. composite mode), and the way to solve it, is similar. Note that I'm not voting to delete the question, just close it, so that no more answers than yours (which is 100% correct) is added. – Alexis Pigeon Sep 15 '14 at 15:27
  • @AlexisPigeon Sorry, I thought it was for deletion :) – Reda Sep 15 '14 at 15:33
  • BTW, feel free to mark your answer as the accepted one, that's quite an [accepted thing to do on SO](http://blog.stackoverflow.com/2009/01/accept-your-own-answers/), in case you didn't know. You'll have to wait for 48 hours though. – Alexis Pigeon Sep 15 '14 at 15:40

1 Answers1

6

Google for the difference between "text mode" and "composite mode". You are using "text mode": the leading of the cell is taken into account; the leading of the paragraph is ignored. If you use "composite mode", it's the other way round.

Try:

PdfPCell c = new PdfPCell(); 
c.addElement(p); 
Reda
  • 1,277
  • 1
  • 13
  • 27