Use a table??

john renfrew 
Right Way Up 



-----Original Message-----
From: GAlfstad [mailto:gloria.alfs...@fpx.com] 
Sent: 10 November 2011 14:40
To: itext-questions@lists.sourceforge.net
Subject: [iText-questions] Paragraph with Images : Setting Alignment

I need to print a (1 to N) items, with an image to the left, and some
attributes to the right. 
<<Image>> *Label:* Value
                Label2: Value2

<<Image>> *Label:* Value
                Label2: Value2

<<Image>>* Label:* Value
                Label2: Value2

My labels are always printing below my images. I had some success when the
alignment on the Image to TEXTWRAP, but since the images are different sizes
when I called image.setScaleAbsolute(float, float) then the labels printed
on the images, and printing of the images versus was sporadically placed. 

        Paragraph paragraphs = new Paragraph();
        paragraphs.setIndentationLeft(70);
        int phonesAdded = 0;
        for (Phone phone : planSummary.getSelectedPhones())
        {
            if (phonesAdded == 3)
            {
                document.add(paragraphs);
                paragraphs = new Paragraph();
                paragraphs.setIndentationLeft(70);
                phonesAdded = 0;   
                document.newPage();
            }
                
            Paragraph phoneParagraph = new Paragraph();
            phoneParagraph.setIndentationLeft(70);
            phoneParagraph.setAlignment(Element.ALIGN_TOP |
Element.ALIGN_LEFT);
            phoneParagraph.setKeepTogether(true);
                        
            Image phoneImage = null;
            try {
                phoneImage = Image.getInstance(imageUrl + phone.getImage());
            } catch (Exception e) {
                e.printStackTrace();
            }
        
            //phoneImage.scalePercent(60);
            phoneImage.scaleAbsolute(137, 275);
            //phoneImage.setAlignment(Image.TEXTWRAP);
            phoneImage.setAlignment(Element.ALIGN_LEFT);
            phoneImage.setIndentationRight(10.0f);

            Paragraph detailsParagraph = new Paragraph();
            Phrase details = new Phrase();
            
            Phrase phonePhrase = new Phrase();
            Chunk phoneChunkLabel = new Chunk("Selected Phone: ");
            phoneChunkLabel.setFont(FONT_10_BOLD);
            phonePhrase.add(phoneChunkLabel);

            Chunk phoneChunk = new Chunk(phone.getManufacturer() + " " +
phone.getName());
            phoneChunk.setFont(FONT_SELECTED_ITEM);
            phonePhrase.add(phoneChunk);
            details.add(phonePhrase);
            
            Phrase pricePhrase = new Phrase();
            Chunk priceChunkLabel = new Chunk("\nSale Price: ");
            pricePhrase.add(priceChunkLabel);

            Chunk priceChunk = new Chunk(phone.getPrice());
            pricePhrase.add(priceChunk);
            details.add(pricePhrase);
            
            
            detailsParagraph.setAlignment(Element.ALIGN_MIDDLE);
            detailsParagraph.add(details);
            
            phoneParagraph.add(phoneImage);
            phoneParagraph.add(detailsParagraph);

            paragraphs.add(phoneParagraph);
            
            phonesAdded++;
    }        
    if (numPhones > 0)
    {
        document.add(paragraphs);
        
    }   

Thanks for any advice!

--
View this message in context:
http://itext-general.2136553.n4.nabble.com/Paragraph-with-Images-Setting-Ali
gnment-tp4023842p4023842.html
Sent from the iText - General mailing list archive at Nabble.com.

----------------------------------------------------------------------------
--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a
reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php



------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to