Re: [iText-questions] Cell Alignment
Rewrite your post in a way that makes sense. Paulo -Original Message- From: Thilip Kumar S [mailto:thili...@suntecgroup.com] Sent: Friday, September 18, 2009 8:52 AM To: itext-questions@lists.sourceforge.net Subject: [iText-questions] Cell Alignment Hi Im trying to generate the PDF with 3 column. My requirement is , I need to have 3 columns in report, Say Cust Name, Account No, Paid Amount. In this case, the first 2 cells should be aligned left, the 3rd one should be aligned right , as its a numeric value. Im trying like the below., PdfPTable pTable = new PdfPTable(3); pTable.setWidthPercentage(100); pTable.setWidths(new float[] {0,80,20}); pTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); pTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); Phrase p1 = new Phrase(arr[0],colFont); Phrase p2 = new Phrase(arr[4],colFont); PdfPCell pcell = new PdfPCell(); pcell.setBorderWidth(0); pcell.setHorizontalAlignment(Element.ALIGN_RIGHT); pcell.setBorder(Rectangle.NO_BORDER); pcell.disableBorderSide(PdfPCell.BOTTOM); pTable.addCell(pcell); pTable.addCell(p1); pTable.addCell(p2); pTable.addCell(); getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT) will align the whole table in to right. But im my case , the Phrase p1 alone should be aligned RIGHT. Can anyone help me. Thanks in Advance Aviso Legal: Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem. Disclaimer: This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message. -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
Re: [iText-questions] Cell Alignment
Instead of using alignment on the cell level I'm using alignment of a paragraph. see the following code: PdfPTable tbl=new PdfPTable(3); PdfPCell cell1; PdfPCell cell2; PdfPCell cell3; Paragraph p; cell1=new PdfPCell(); cell2=new PdfPCell(); cell3=new PdfPCell(); p=new Paragraph(text1,myFont); p.setAlignment(Element.ALIGN_LEFT); cell1.addElement(p); tbl.addCell(cell1); p=new Paragraph(text2,myFont); p.setAlignment(Element.ALIGN_LEFT); cell2.addElement(p); tbl.addCell(cell2); p=new Paragraph(text3,myFont); p.setAlignment(Element.ALIGN_RIGHT); cell3.addElement(p); tbl.addCell(cell3); 2009/9/18 Thilip Kumar S thili...@suntecgroup.com Hi Im trying to generate the PDF with 3 column. My requirement is , I need to have 3 columns in report, Say Cust Name, Account No, Paid Amount. In this case, the first 2 cells should be aligned left, the 3rd one should be aligned right , as its a numeric value. Im trying like the below., PdfPTable pTable = new PdfPTable(3); pTable.setWidthPercentage(100); pTable.setWidths(new float[] {0,80,20}); pTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); pTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); Phrase p1 = new Phrase(arr[0],colFont); Phrase p2 = new Phrase(arr[4],colFont); PdfPCell pcell = new PdfPCell(); pcell.setBorderWidth(0); pcell.setHorizontalAlignment(Element.ALIGN_RIGHT); pcell.setBorder(Rectangle.NO_BORDER); pcell.disableBorderSide(PdfPCell.BOTTOM); pTable.addCell(pcell); pTable.addCell(p1); pTable.addCell(p2); pTable.addCell(); getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT) will align the whole table in to right. But im my case , the Phrase p1 alone should be aligned RIGHT. Can anyone help me. Thanks in Advance This electronic mail (including any attachment thereto) may be confidential and privileged and is intended only for the individual or entity named above. Any unauthorized use, printing, copying, disclosure or dissemination of this communication may be subject to legal restriction or sanction. Accordingly, if you are not the intended recipient, please notify the sender by replying to this email immediately and delete this email (and any attachment thereto) from your computer system...Thank You. -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/ -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
Re: [iText-questions] Cell Alignment
Kumar: Even with the suggested solution, your table is not going to work very well. For example, setWidths() does not work the way you're using it. Secondly, why are you using a command that sets the alignment for all cells to right, and then setting individual cells to right? I am fairly sure this is what Paulo meant when he said you need to repost this question. He's right. You have not understood how tables are created. Start by studying chapter 6 in the book. ---mr. bean Thilip Kumar S wrote: Hi Im trying to generate the PDF with 3 column. My requirement is , I need to have 3 columns in report, Say Cust Name, Account No, Paid Amount. In this case, the first 2 cells should be aligned left, the 3rd one should be aligned right , as its a numeric value. Im trying like the below., PdfPTable pTable = new PdfPTable(3); pTable.setWidthPercentage(100); pTable.setWidths(new float[] {0,80,20}); pTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); pTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); Phrase p1 = new Phrase(arr[0],colFont); Phrase p2 = new Phrase(arr[4],colFont); PdfPCell pcell = new PdfPCell(); pcell.setBorderWidth(0); pcell.setHorizontalAlignment(Element.ALIGN_RIGHT); pcell.setBorder(Rectangle.NO_BORDER); pcell.disableBorderSide(PdfPCell.BOTTOM); pTable.addCell(pcell); pTable.addCell(p1); pTable.addCell(p2); pTable.addCell(); getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT) will align the whole table in to right. But im my case , the Phrase p1 alone should be aligned RIGHT. Can anyone help me. Thanks in Advance ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/ -- View this message in context: http://www.nabble.com/Cell-Alignment-tp25504786p25505623.html Sent from the iText - General mailing list archive at Nabble.com. -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
Re: [iText-questions] cell alignment
[EMAIL PROTECTED] wrote: hallo all together i have a huge problem! Your huge problem being unable to read the documentation? if i m adding paragraphs to a cell the aligment of align_middle isn't working. You are mixing 'text mode' with 'composite mode' in your code snippet. The first thing you need to know that a PdfPCell is treated as a ColumnText object (see chapter 6 and 7 of the book). There are two ways to add content to a ColumnText object: - in text mode - in composite mode When you add objects in text mode, the alignment of the object is ignored. You have to set the alignment at the ColumnText/PdfPCell level. When you add objects in composite mode, the alignment of the objects is preserved, but you may loose ColumnText/PdfPCell properties. To solve your problem, use: [text mode] Phrase phrase = new Phrase(Hello); PdfPCell cell = new PdfPCell(phrase); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPadding(padding); table.addCell(cell); or [composite mode] PdfPCell cell = new PdfPCell(); Paragraph p = new Paragraph(Hello); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); table.addCell(cell); Read chapter 6 and 7 of iText in Action for more info. -- This answer is provided by 1T3XT BVBA - Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Do you like iText? Buy the iText book: http://www.1t3xt.com/docs/book.php Or leave a tip: https://tipit.to/itexttipjar