On 27/10/2012 20:21, Sweet, Paul CCS wrote:
For the chunk, I'm adding for the Drawing Number _PWS0002_, _PWS000__3_,
_PWS000__4_,  &___PWS000__5_.  What I expect is these drawing numbers to
be the URL.

And that's exactly the case when I adapt your example.
See attachments.

First I wrote the code you should have written: using PdfPTable.
Maybe you have a specific reason for not using PdfPTable, so I also added an example using separator chunks.
Finally, I used your "poor man's table" solution by padding the strings.

In all try cases, the underlined chunk marks the clickable area.

Attachment: table_link.pdf
Description: Adobe PDF document

package examples.tables;

import java.io.FileOutputStream;
import java.io.IOException;

import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.text.pdf.draw.VerticalPositionMark;

public class TableWithLinks {
    /**
     * Creates a PDF document.
     * @param filename the path to the new PDF document
     * @throws    DocumentException 
     * @throws    IOException 
     */
    public static void main(String[] args)
        throws DocumentException, IOException {
        // step 1
        Document document = new Document();
        // step 2
        PdfWriter.getInstance(document, new FileOutputStream("table_link.pdf"));
        // step 3
        document.open();
        // step 4
        document.add(new Paragraph("USE A PDFPTABLE:"));
        
        PdfPTable table = new PdfPTable(9);
        table.setWidthPercentage(100);
        table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        table.setWidths(new int[]{ 3, 8, 8, 3, 3, 12, 12, 8, 3 });
        table.addCell("10");
        table.addCell("PWS00002");
        table.addCell("5.0000");
        table.addCell("ea");
        table.addCell("M");
        table.addCell("BOLT, HEX HD");
        table.addCell("1/2-13 X 4-1/2 LG");
        Chunk chunk = new Chunk("PWS00002");
        chunk.setAnchor("http://itextpdf.com";);
        chunk.setUnderline(1, -1);
        table.addCell(new Phrase(chunk));
        table.addCell("C");
        document.add(table);
        document.add(Chunk.NEWLINE);

        document.add(new Paragraph("USE SEPARATOR CHUNKS:"));
        Chunk tab1 = new Chunk(new VerticalPositionMark(), 24, true);
        Chunk tab2 = new Chunk(new VerticalPositionMark(), 88, true);
        Chunk tab3 = new Chunk(new VerticalPositionMark(), 152, true);
        Chunk tab4 = new Chunk(new VerticalPositionMark(), 176, true);
        Chunk tab5 = new Chunk(new VerticalPositionMark(), 200, true);
        Chunk tab6 = new Chunk(new VerticalPositionMark(), 300, true);
        Chunk tab7 = new Chunk(new VerticalPositionMark(), 428, true);
        Chunk tab8 = new Chunk(new VerticalPositionMark(), 500, true);
        Paragraph p = new Paragraph("20");
        p.add(tab1);
        p.add("PWS0003");
        p.add(tab2);
        p.add("50.0000");
        p.add(tab3);
        p.add("ea");
        p.add(tab4);
        p.add("M");
        p.add(tab5);
        p.add("PART3");
        p.add(tab6);
        p.add("TESTING NEW PQ");
        p.add(tab7);
        p.add(chunk);
        p.add(tab8);
        p.add("C");
        document.add(p);
        document.add(Chunk.NEWLINE);
        
        document.add(new Paragraph("YOUR WAY:"));
        p = new Paragraph("30     PWS0004     98.0000 ea  M    PART4            
 BLAH BLAH BLAH   ");
        p.add(chunk);
        p.add(" C");
        document.add(p);
        
        // step 5
        document.close();
    }
}
------------------------------------------------------------------------------
WINDOWS 8 is here. 
Millions of people.  Your app in 30 days.
Visit The Windows 8 Center at Sourceforge for all your go to resources.
http://windows8center.sourceforge.net/
join-generation-app-and-make-money-coding-fast/
_______________________________________________
iText-questions mailing list
[email protected]
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