Re: [iText-questions] Alignment of text in a Paragraph within a Cell
If you need multiple paragraphs in a single cell with different alignments, then I think you will have to use a nested inner table and set the alignment on the individual cells in the inner table. Also, be aware that there are known problems with nested tables inside Table. You would probably be better off using PdfPTable and the itext-paulo-139 version at itextpdf.sf.net. - Original Message - From: <[EMAIL PROTECTED]> To: "Steve Appling" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, October 12, 2004 9:44 AM Subject: Re: [iText-questions] Alignment of text in a Paragraph within a Cell > > > > > Steve, > > Thanks for ur reply. This code works. > > I have the another requirement where i need to add the following rich > text to the cell. > > String htmlText = "Left aligment align=center>center alignmentRight alignment"; > > I am using the SAXiTextHandler.java as the handler to parse the > richtext. I defined a class TextElementArrayWriter which implements the > DocListener and using this object during creation of the handler object. > Here i am attaching the TextElementArrayWriter.java class > > The htmlText String contains 3 paragraphs with different alignments. > So please let me know how to keep the alignment for that cell with many > paragraphs. > --- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl ___ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions
Re: [iText-questions] Alignment of text in a Paragraph within a Cell
Steve, Thanks for ur reply. This code works. I have the another requirement where i need to add the following rich text to the cell. String htmlText = "Left aligmentcenter alignmentRight alignment"; I am using the SAXiTextHandler.java as the handler to parse the richtext. I defined a class TextElementArrayWriter which implements the DocListener and using this object during creation of the handler object. Here i am attaching the TextElementArrayWriter.java class The htmlText String contains 3 paragraphs with different alignments. So please let me know how to keep the alignment for that cell with many paragraphs. /** This class implements the document listener interface. * Instead of writing to a document, this class adds content * to an element */ public class TextElementArrayWriter implements DocListener { private TextElementArray element; public TextElementArrayWriter(TextElementArray element) { this.element = element; } public void open() { } public boolean setPageSize(Rectangle pageSize) { return false; } public boolean add(Watermark watermark) { return false; } public void removeWatermark() { } public boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom) { return false; } public boolean newPage() throws DocumentException { return false; } public void setHeader(HeaderFooter header) { } public void resetHeader() { } public void setFooter(HeaderFooter footer) { } public void resetFooter() { } public void resetPageCount() { } public void setPageCount(int pageN) { } public void clearTextWrap() throws DocumentException { } public void close() { } /** * Adds the given element to this listener's cell * @param addElement element to add * @return true if added successfully, false if not * @throws DocumentException */ public boolean add(Element addElement) throws DocumentException { element.add(addElement); return true; } } Thanks Srinivasulu Vempuluru "Steve Appling" <[EMAIL PROTECTED]To: [EMAIL PROTECTED], Srinivasu L. ring.com> Vempuluru/VEND/MD/[EMAIL PROTECTED] cc: 10/11/2004 04:57 Subject: Re: [iText-questions] Alignment of text in a Paragraph within a Cell PM Use code like this with the current version: Cell cell = new Cell(p); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); aTable.addCell(cell); It works when set from the cell level, but the paragraph alignment does not apply. I think this could be considered a bug. It is easy to fix in the constructor for Cell(Paragraph), but if you use the default constructor for Cell or PdfPCell, it is a little messier. You would need to probably keep another alignment state that works like ALIGN_LEFT, but indicates that current alignment had been set explicitly. Then Cell.addElement or PdfPCell.addElement would have to override the default alignment if it hadn't been set explicitly yet. Seems messy. Paulo, are you interested in supporting this? I'll add it if you think it should work this way. - Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, October 11, 2004 1:07 PM Subject: [iText-questions] Alignment of text in a Paragraph within a Cell > > > > > Hi, > > I am trying to align the text in a paragraph with a cell using the > following code. It works fine in RTF. But it is not working in PDF. > > In PDF it is displaying all the text as Left aligned. > > Please let me know the fix for this. > > Document document = new Document(PageSize.A4); > PdfWriter.getInstance(document, new > FileOutputStream("c:\\alogs\\Orientation.pdf")
Re: [iText-questions] Alignment of text in a Paragraph within a Cell
Leave it as it is. Any change there would break all the existing code. Best Regards, Paulo Soares - Original Message - From: "Steve Appling" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Monday, October 11, 2004 21:57 Subject: Re: [iText-questions] Alignment of text in a Paragraph within a Cell > Use code like this with the current version: > Cell cell = new Cell(p); > cell.setHorizontalAlignment(Element.ALIGN_RIGHT); > aTable.addCell(cell); > > It works when set from the cell level, but the paragraph alignment does not apply. I think this > could be considered a bug. > > It is easy to fix in the constructor for Cell(Paragraph), but if you use the default constructor for > Cell or PdfPCell, it is a little messier. > You would need to probably keep another alignment state that works like ALIGN_LEFT, but indicates > that current alignment had been set explicitly. Then Cell.addElement or PdfPCell.addElement would > have to override the default alignment if it hadn't been set explicitly yet. Seems messy. > > Paulo, are you interested in supporting this? I'll add it if you think it should work this way. > > - Original Message - > From: <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Monday, October 11, 2004 1:07 PM > Subject: [iText-questions] Alignment of text in a Paragraph within a Cell > > > > > > > > > > > > Hi, > > > > I am trying to align the text in a paragraph with a cell using the > > following code. It works fine in RTF. But it is not working in PDF. > > > > In PDF it is displaying all the text as Left aligned. > > > > Please let me know the fix for this. > > > > Document document = new Document(PageSize.A4); > > PdfWriter.getInstance(document, new > > FileOutputStream("c:\\alogs\\Orientation.pdf")); > > document.open(); > > Paragraph p = new Paragraph("Left Alignment"); > > p.setAlignment("left"); > > Table aTable = new Table(2,2); > > aTable.addCell(new Cell(p)); > > p = new Paragraph("Right Alignment"); > > p.setAlignment("right"); > > aTable.addCell(new Cell(p)); > > p = new Paragraph("Center Alignment"); > > p.setAlignment("center"); > > aTable.addCell(new Cell(p)); > > aTable.addCell(new Cell(new Phrase("col22: ", > > IReportConstants.FONT_TABLE_COLUMN))); > > document.add(aTable); > > document.close(); > > > > Thanks > > Srinivasulu Vempuluru > > > > > > > > > > --- > > This SF.net email is sponsored by: IT Product Guide on ITManagersJournal > > Use IT products in your business? Tell us what you think of them. Give us > > Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more > > http://productguide.itmanagersjournal.com/guidepromo.tmpl > > ___ > > iText-questions mailing list > > [EMAIL PROTECTED] > > https://lists.sourceforge.net/lists/listinfo/itext-questions > > > > > > > --- > This SF.net email is sponsored by: IT Product Guide on ITManagersJournal > Use IT products in your business? Tell us what you think of them. Give us > Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more > http://productguide.itmanagersjournal.com/guidepromo.tmpl > ___ > iText-questions mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/itext-questions --- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl ___ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions
Re: [iText-questions] Alignment of text in a Paragraph within a Cell
Use code like this with the current version: Cell cell = new Cell(p); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); aTable.addCell(cell); It works when set from the cell level, but the paragraph alignment does not apply. I think this could be considered a bug. It is easy to fix in the constructor for Cell(Paragraph), but if you use the default constructor for Cell or PdfPCell, it is a little messier. You would need to probably keep another alignment state that works like ALIGN_LEFT, but indicates that current alignment had been set explicitly. Then Cell.addElement or PdfPCell.addElement would have to override the default alignment if it hadn't been set explicitly yet. Seems messy. Paulo, are you interested in supporting this? I'll add it if you think it should work this way. - Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, October 11, 2004 1:07 PM Subject: [iText-questions] Alignment of text in a Paragraph within a Cell > > > > > Hi, > > I am trying to align the text in a paragraph with a cell using the > following code. It works fine in RTF. But it is not working in PDF. > > In PDF it is displaying all the text as Left aligned. > > Please let me know the fix for this. > > Document document = new Document(PageSize.A4); > PdfWriter.getInstance(document, new > FileOutputStream("c:\\alogs\\Orientation.pdf")); > document.open(); > Paragraph p = new Paragraph("Left Alignment"); > p.setAlignment("left"); > Table aTable = new Table(2,2); > aTable.addCell(new Cell(p)); > p = new Paragraph("Right Alignment"); > p.setAlignment("right"); > aTable.addCell(new Cell(p)); > p = new Paragraph("Center Alignment"); > p.setAlignment("center"); > aTable.addCell(new Cell(p)); > aTable.addCell(new Cell(new Phrase("col22: ", > IReportConstants.FONT_TABLE_COLUMN))); > document.add(aTable); > document.close(); > > Thanks > Srinivasulu Vempuluru > > > > > --- > This SF.net email is sponsored by: IT Product Guide on ITManagersJournal > Use IT products in your business? Tell us what you think of them. Give us > Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more > http://productguide.itmanagersjournal.com/guidepromo.tmpl > ___ > iText-questions mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/itext-questions > --- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl ___ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions
[iText-questions] Alignment of text in a Paragraph within a Cell
Hi, I am trying to align the text in a paragraph with a cell using the following code. It works fine in RTF. But it is not working in PDF. In PDF it is displaying all the text as Left aligned. Please let me know the fix for this. Document document = new Document(PageSize.A4); PdfWriter.getInstance(document, new FileOutputStream("c:\\alogs\\Orientation.pdf")); document.open(); Paragraph p = new Paragraph("Left Alignment"); p.setAlignment("left"); Table aTable = new Table(2,2); aTable.addCell(new Cell(p)); p = new Paragraph("Right Alignment"); p.setAlignment("right"); aTable.addCell(new Cell(p)); p = new Paragraph("Center Alignment"); p.setAlignment("center"); aTable.addCell(new Cell(p)); aTable.addCell(new Cell(new Phrase("col22: ", IReportConstants.FONT_TABLE_COLUMN))); document.add(aTable); document.close(); Thanks Srinivasulu Vempuluru --- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl ___ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions