hmm, I do not clearly get it, the width of the cell isn't calculated
according to the font I'm using, but to the BaseFont's width.
Is that so?
Actually I need the diactriced characters, therefore the BaseFont isn't
enough for me.
So in clear, there are no clue how to solve it?
btw, I'm even using font size 9, so the difference should be even
smaller^^
Gregan, Miroslav wrote:
> Hi all,
>
> When writing text rotated to 90`, it happen that sometimes the last
> character is not written.
> For example in this PDF there should be "AAA1" in the table instead of
> "AAA".
>
> Do you have any clue
If I add the text "AAA1" with font Tahoma and font size 12 to a
ColumnText, iText tells me the with is 28.103973 pt.
If I ask the BaseFont Tahoma for the width of the same String, I get
28.104 pt. In other words: the problem is smaller than a 10,000th of a
point.
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info
________________________________
From: Gregan, Miroslav
Sent: Wednesday, April 15, 2009 4:46 PM
To: '[email protected]'
Subject: Vertical rotated text missing the last character in PdfPTable
Hi all,
When writing text rotated to 90`, it happen that sometimes the last
character is not written.
For example in this PDF there should be "AAA1" in the table instead of
"AAA".
Do you have any clue how to have the expected content?
Thank you.
Kind regards,
Miro
PS I'm testing the following code:
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.PageSize;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
public class Test {
public static void main(String[] args) {
FontFactory.register("C:\\WINNT\\Fonts\\tahoma.ttf");
Font fontNormal = FontFactory.getFont("Tahoma", BaseFont.IDENTITY_H,
9f);
Document document = null;
FileOutputStream fileOutputStream = null;
PdfWriter pdfWriter = null;
try {
document = new Document(PageSize.A4);
fileOutputStream = new
FileOutputStream("D:\\FU20-Tool\\testWorkspace\\test.pdf");
pdfWriter = PdfWriter.getInstance(document, fileOutputStream);
} catch (DocumentException de) {
System.out.println(de.toString());
} catch (FileNotFoundException fnfe) {
System.out.println(fnfe.toString());
}
if ((document != null) && (fileOutputStream != null) && (pdfWriter !=
null)) {
document.open();
PdfPTable mainTable = new PdfPTable(4);
mainTable.getDefaultCell().setNoWrap(true);
float[] columnWidths = { 70f, 16f, 16f, 16f };
String[] columnContent = { "ABC1", "AAA1", "BBB1", "CCC"};
try {
mainTable.setTotalWidth(columnWidths);
} catch (DocumentException e) {
System.out.println(e.toString());
}
mainTable.addCell(new Phrase(columnContent[0], fontNormal));
mainTable.getDefaultCell().setRotation(90);
for (int i = 1; i < columnContent.length; i++) {
mainTable.addCell(new Phrase(columnContent[i], fontNormal));
}
mainTable.writeSelectedRows(0, -1, 2f, PageSize.A4.getHeight()-2f,
pdfWriter.getDirectContent());
document.close();
try {
fileOutputStream.close();
} catch (IOException e) {
System.out.println(e.toString());
}
}
}
}
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
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