Hi, I am an iText newbie, that's why I'd like to firstly introduce myself. My name is Arvid and I am a student at the Hamburg University of Applied Sciences in Hamburg, Germany. Maybe my English isn't that good, 'cause I'm a German and I actually don't speak English every day. ;-) So, please apologize.
I already tried to find some entries in the mailing lists concerning my problem, but at first I only got the failure: "Timed out waiting for response from Search Server." And now I just can't find any solution forexactly that problem I have, although there are a few posts with similar problems. So I directly ask you.
I am working on a tool that gernerates PDF files with tables by using the iText library. It's some kind of schedule.However, let me describe my problem now. The table that has to be generated has cells with different text alignments setted by the method
PDFPCell#setHorizontalAlignment(int). It does work somehow, but the result doesn't look like what I expected. The left aligned phrases are absolutely fine. The centered and the right aligned phrases on the other hand are wrong positioned. The right aligned phrases are nearly completely outside their cells. I thought I did something wrong, so I programmed a very simple sample program. This is the code I used for generating that simple table: // initialize the document and the writer Document document = new Document(PageSize.A4, 10, 10, 10, 10); PdfWriter.getInstance(document, new FileOutputStream( new File(System.getProperty("user.dir"), "test.pdf"))); // open the document document.open(); // initialize the table with 3 columns PdfPTable table = new PdfPTable(3); table.setWidthPercentage(80); // initialize the cells PdfPCell cell1 = new PdfPCell(new Phrase("left_aligned")); cell1.setHorizontalAlignment(Element.ALIGN_LEFT); PdfPCell cell2 = new PdfPCell(new Phrase("centered")); cell2.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell cell3 = new PdfPCell(new Phrase("right_aligned")); cell3.setHorizontalAlignment(Element.ALIGN_RIGHT); // add the cells to the table table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); // add the table to the document document.add(table); // close the document document.close(); As you can see it's very simple. :-) I added a file attachment to the mail. There you can find the generated PDF file with the programm code above. Look at the table's 2nd and at the 3rd cell. Their phrases aren't really center respectivly right aligned. The 3rd cell's phrase is almost outside its cell. That can't be alright, does it? Oh, by the way my Java version is 1.5 and the iText library I use is the latest version 2.0.4. So, what is my mistake? What do I have to do to get the correct alignments? Hopefully you can help me. I will be very thankful! =) Best regards from Hamburg, Germany Arvid
test.pdf
Description: application/octetstream
------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/