Paulo, thanks for your quick response. Here is the approach I'm trying.
At 'Instance 1' the hyperlink image works as advertised linking to a
specified URL. However at 'Instance 2', all I see is the image but the
hyperlink does not work. Is there something obvious that I am missing?
Thanks again for your help.
public void generatePDF(OutputStream stream){
Document document = new Document();
PdfWriter.getInstance(document, stream);
document.open();
int widthPercentage = 84;
int[] widths = {
40,
25,
12,
18,
18,
12,
12,
20
};
//Instance 1
document.add(getHyperLinkedImageCell(25, 10, "someUrl",
"imageSourceUrl"));
document.add(new Paragraph(10, " "));
PdfPTable table = new PdfPTable(8);
table.getDefaultCell().setPadding(3);
table.setWidths(widths);
table.setWidthPercentage(widthPercentage);
table.addCell(getQuoteDetailPDFTableCell(6, "Column1",
1));
table.addCell(getQuoteDetailPDFTableCell(6, "Column2",
1));
table.addCell(getQuoteDetailPDFTableCell(6, "Column3",
1));
table.addCell(getQuoteDetailPDFTableCell(6, "Column4",
1));
table.addCell(getQuoteDetailPDFTableCell(6, "Column5",
1));
table.addCell(getQuoteDetailPDFTableCell(6, "Column6",
1));
table.addCell(getQuoteDetailPDFTableCell(6, "Column7",
1));
//Instance 2
table.addCell(getHyperLinkedImageCell(25, 10, "someUrl",
"imageSourceUrl"));
document.add(table);
document.close();
}
private Image getHyperLinkedImageCell(int scaleWidth, int
scaleHeight, String url, String imageSourceUrl){
Image image = Image.getInstance(new
URL(imageSourceUrl));
image.scaleToFit(scaleWidth, scaleHeight);
image.setAnnotation(new Annotation(0,0,0,0,url));
return image;
}
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Paulo Soares
Sent: Tuesday, January 16, 2007 4:53 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Adding hyperlink image to a PdfPTable
It will work if the table is not inside a template.
Paulo
----- Original Message -----
From: "Anoop Kulkarni" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, January 16, 2007 10:16 PM
Subject: [iText-questions] Adding hyperlink image to a PdfPTable
I have a question on how to add a hyperlinked image to a PdfPTable.
I have managed to create a hyperlinked image (Ref:
http://threebit.net/mail-archive/itext-questions/msg00633.html) as well
as adding an anchor like
Image image = Image.getInstance(new URL(imageSource));
Chunk chunk = new Chunk(image,0,0);
Anchor anchor = new Anchor(chunk);
anchor.setReference(url);
These approaches work fine as long as you add the Image/Phrase/Anchor
directly to the Document. However as soon as I create a PdfPTable and to
try to add the hyperlinked image/anchor/Phrase/PdfPCell as a
pdfPTable.addCell(..) the hyperlink does not work.
I have tried googling and going through the tutorials and itext
archives, but haven't found anything which could show me something that
I am missing.
I hope someone here could point me in the right direction.
Thanks for your time,
Anoop
------------------------------------------------------------------------
--------
>
------------------------------------------------------------------------
-
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to
share
> your
> opinions on IT & business topics through brief surveys - and earn cash
>
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE
V
------------------------------------------------------------------------
--------
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> Buy the iText book: http://itext.ugent.be/itext-in-action/
>
------------------------------------------------------------------------
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE
V
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/