PdfPCell.setUseAscender() > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Martin Resch (adaptions GmbH) > Sent: Wednesday, October 27, 2004 9:22 AM > To: [EMAIL PROTECTED] > Subject: [iText-questions] leading and alignment in PdfPCell > > Hello, > > I've a PdfPTable with a PdfPCell (with absolute height, > no padding) > inside. In the cell there is a Phrase. The Phrase is aligned with > PdfPCell.setVerticalAlignment(). Everything is all right as > long as there > isn't a leading. > After calling the function PdfPCell.setLeading(x, 0) > with alignment > middle or top the text isn't in the middle/top but there is > an additional > space above the text. > Why is this so and how is the space calculated? My goal > is to place > the text with leading in the middle and the first line directly on top > respectively. > > Following code gives an example: > > public static void main(String[] args) { > Document document = new Document(); > > try { > PdfWriter writer = PdfWriter.getInstance(document, new > FileOutputStream("leading_alignment.pdf")); > > document.open(); > > PdfContentByte cb = writer.getDirectContent(); > > float x = 25; > float y = 800; > float width; > float height; > > for (int i = 1; i <= 4; i++) { > PdfPTable table = new PdfPTable(1); > table.getDefaultCell().setPadding(0); > table.getDefaultCell().setBorder(PdfPCell.NO_BORDER); > table.setTotalWidth(130); > > Phrase phrase = new Phrase("my Text\nnext line", > FontFactory.getFont(FontFactory.HELVETICA, 30f)); > > PdfPCell cell = new PdfPCell(phrase); > cell.setPadding(0); > cell.setFixedHeight(300); > cell.setBorderWidth(.1f); > cell.setBorder(PdfPCell.BOX); > > if (i == 1) { > cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); > } else if (i == 2) { > cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); > cell.setLeading(60, 0); > } else if (i == 3) { > cell.setVerticalAlignment(PdfPCell.ALIGN_TOP); > } else if (i == 4) { > cell.setVerticalAlignment(PdfPCell.ALIGN_TOP); > cell.setLeading(60, 0); > } > > table.addCell(cell); > table.writeSelectedRows(0, 1, x, y, cb); > x = x + 140; > } > > // middleline of the first two cells > cb.moveTo(25, 650); > cb.setColorStroke(Color.BLACK); > cb.setLineWidth(1f); > cb.lineTo(295, 650); > cb.stroke(); > > document.close(); > } catch (Exception e) { > e.printStackTrace(); > } > } > > > > Thanks for your help! > > > Best regards, > > Martin >
------------------------------------------------------- This SF.Net email is sponsored by: Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's Choice Award Winner for best database on Linux. http://ads.osdn.com/?ad_idU88&alloc_id065&op=click _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions