See attached PDF output.

Hope this helps.. seems to be relatively easy :-)

package whatever.you.want;
 
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.geom.Rectangle2D;
import java.io.FileOutputStream;
import java.io.IOException;

import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Image;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.DefaultFontMapper;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfWriter;
 
public class ArrayContentsIntoPdfPCell {
 
        private static final float POINT_FACTOR = 72f / 25.4f;
        private static final float HEADER_SPACE = 0f * POINT_FACTOR;
        private static final float LEFTMARGIN = 10f * POINT_FACTOR;
        private static final float RIGHTMARGIN = 9f * POINT_FACTOR;
        private static final float TOPMARGIN = 12f * POINT_FACTOR;
        private static final float BOTTOMMARGIN = 30f * POINT_FACTOR;
        private static final float HEADER_HEIGHT = 20f * POINT_FACTOR;
        //private static Font arialSize8White = new Font("Times New Roman", 
Font.PLAIN, 8);
        private static Font arialSize8White = FontFactory.getFont("Arial", "", 
true, 8, java.awt.Font.PLAIN, 
            java.awt.Color.white);
        private static Font arialSize8 = FontFactory.getFont("Arial", "", true, 
8, java.awt.Font.PLAIN, 
            java.awt.Color.black);
        private static Font arialSize8Bold = FontFactory.getFont("Arial", "", 
true, 8, java.awt.Font.BOLD, 
            java.awt.Color.black);
        
        
        public static final String RESULT = "C:\\Temp\\ArrayToCell.pdf";
 
        public static void main(String[] args) {
                
                Document.compress = false;
                Document document = new Document(PageSize.A4, LEFTMARGIN, 
RIGHTMARGIN, TOPMARGIN
                        + HEADER_HEIGHT, BOTTOMMARGIN);
                try {
                        PdfWriter writer = PdfWriter.getInstance(document, new 
FileOutputStream(RESULT));
                        writer.setFullCompression();
                        document.open();
                        

                        // *** Example method 1 ***
                        PdfPTable arrayTable1 = new PdfPTable(1);
                        arrayTable1.setHorizontalAlignment(Element.ALIGN_LEFT);
                        
                        String[] strings1 = new String [] 
{"Bob","James","Maximo"};
                        PdfPCell arrayDetailsCell1 = new PdfPCell();
                        for (int i = 0; i < strings1.length; i++) {
                                arrayDetailsCell1.addElement(new 
Phrase(strings1[i]));
                        }
                                                                                
                    // Add the cell to the table
                    arrayTable1.addCell(arrayDetailsCell1);
                    
                    // Add table to the document 
                    document.add(arrayTable1);
                    
                    // *** Example method 2 ***
                    PdfPTable arrayTable2 = new PdfPTable(1);
                    arrayTable2.setHorizontalAlignment(Element.ALIGN_LEFT);
                    
                        String[] strings2 = new String [] 
{"Bob","James","Maximo"};
                        PdfPCell arrayDetailsCell2 = new PdfPCell();
                        for (int i = 0; i < strings2.length; i++) {
                                arrayDetailsCell2.addElement(new 
Chunk(strings2[i]));
                        }
                                                                                
                    // Add the cell to the table
                    arrayTable2.addCell(arrayDetailsCell2);
                    
                    // Add table to the document 
                    document.add(arrayTable2);
                    
                    // *** Example method 3 ***
                        PdfPTable arrayTable3 = new PdfPTable(1);
                        arrayTable3.setHorizontalAlignment(Element.ALIGN_LEFT);
                        
                        String[] strings3 = new String [] 
{"Bob","James","Maximo"};
                        Phrase phrase1 = new Phrase(strings3[0]);
                        Phrase phrase2 = new Phrase(strings3[1]);
                        Phrase phrase3 = new Phrase(strings3[2]);
                        PdfPCell arrayDetailsCell3 = new PdfPCell();
                        
                        arrayDetailsCell3.addElement(phrase1);
                        arrayDetailsCell3.addElement(phrase2);
                        arrayDetailsCell3.addElement(phrase3);
                                                                                
                    // Add the cell to the table
                    arrayTable3.addCell(arrayDetailsCell3);
                    
                    // Add table to the document 
                    document.add(arrayTable3);
                    
                } catch (DocumentException de) {
                        System.err.println(de.getMessage());
                } catch (IOException ioe) {
                        System.err.println(ioe.getMessage());
                }
                // Close Document
                document.close();
        }
}

-----Original Message-----
From: d_dolan [mailto:[email protected]]
Sent: 19 July 2010 18:52
To: [email protected]
Subject: [iText-questions] Dump contents of array list into one cell



I am trying to dump a collection of data from a array list into one cell. 
Then when the array list is empty move onto the next one.  I have tried
every combination of For loops and Do while loops but cannot get it to work
correctly.  Looking for a push in the right direction.

Any help would be greatly appreciated.  Thanks
-- 
View this message in context: 
http://itext-general.2136553.n4.nabble.com/Dump-contents-of-array-list-into-one-cell-tp2294379p2294379.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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/

Land Registry's House Price Index is now live. www.landregistry.gov.uk

If you have received this e-mail and it was not intended for you, please let us 
know, and then delete it. Please treat our communications in confidence, as you 
would expect us to treat yours. Land Registry checks all mail and attachments 
for known viruses, however, you are advised that you open any attachments at 
your own risk.



The original of this email was scanned for viruses by the Government Secure 
Intranet virus scanning service supplied by Cable&Wireless Worldwide in 
partnership with MessageLabs. (CCTM Certificate Number 2009/09/0052.) On 
leaving the GSi this email was certified virus free.
Communications via the GSi may be automatically logged, monitored and/or 
recorded for legal purposes.

Attachment: ArrayToCell.pdf
Description: ArrayToCell.pdf

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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/

Reply via email to