Hi all;
And a follow-up to this (still trying to figure it out). If I call
textToWrite.setLeading(24f); then nothing is displayed. Shouldn't the first
line still be displayed no matter how large the leading?
And reading the iText book about setLeading, I think when passing a single
float it's the full height of the line plus leading, not just the leading -
correct?
Thanks - dave
From: David Thielen
Sent: Tuesday, December 07, 2010 3:58 PM
To: '[email protected]'
Subject: Why does this draw the text outside of ColumnText.setSimpleColumn()?
Code:
FontFactory.registerDirectories();
Document document = new Document(new
com.lowagie.text.Rectangle(0, 0, 8.5f * 72.0f, 11 * 72));
PdfWriter writer =
PdfWriter.getInstance(document, new FileOutputStream("test.pdf"));
document.open();
PdfContentByte pdfContByte =
writer.getDirectContent();
String str = "This is a ";
Font fnt = FontFactory.getFont("Calibri",
BaseFont.IDENTITY_H, true, 11, 0);
ColumnText textToWrite = new
ColumnText(pdfContByte);
textToWrite.setAlignment(0);
textToWrite.setLeading(2.4f);
float xLeft = 72.0f;
float xRight = 1600.0f;
float yTop = 713.2f;
float yBottom = 702.25f;
textToWrite.setSimpleColumn(xLeft, yBottom,
xRight, yTop);
Chunk chunk = new Chunk(str, fnt);
textToWrite.addText(chunk);
// write the text
textToWrite.go();
// draw the rectangle
pdfContByte.moveTo(xLeft, yTop);
pdfContByte.lineTo(xRight, yTop);
pdfContByte.lineTo(xRight, yBottom);
pdfContByte.lineTo(xLeft, yBottom);
pdfContByte.lineTo(xLeft, yTop);
pdfContByte.stroke();
document.close();
David Thielen - CTO/founder
303-499-2544 x1185
720-352-0676 (cell)
www.windwardreports.com<http://www.windwardreports.com/>
World's coolest blog - Windward
Wrocks!<http://blogs.windwardreports.com/davidt/>
------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php