Hyperlink to cell content

Hi support,

Please take a look on the following code and note that, at runtime, the document cannot be saved :

Pdf pdf1 = new Pdf();
Section sec1 = pdf1.getSections().add();
Text text1 = new Text(sec1);
Segment segment1 = text1.getSegments().add(“link1”); //$NON-NLS-1$
segment1.getTextInfo().setUnderLine(true);
segment1.setHyperLink(new HyperLinkToLocalPdf(“bmk1”)); //$NON-NLS-1$
sec1.getParagraphs().add(text1);
Table table = new Table(sec1);
//add a row
Row row1 = new Row(table);
table.getRows().add(row1);
Cell cell11 = row1.getCells().add();
Text txt = new Text(cell11);
cell11.getParagraphs().add(txt);
txt.getSegments().add(new Segment(txt, “A”)); //$NON-NLS-1$
Segment seg = new Segment(txt, " "); //$NON-NLS-1$
seg.setID(“bmk1”); //$NON-NLS-1$
txt.getSegments().add(seg);
//Segment seg1 = new Segment(txt, “B”); //$NON-NLS-1$
//txt.getSegments().add(seg1);
sec1.getParagraphs().add(table);
try
{
FileOutputStream out = new FileOutputStream(new File(“C:/Temp/HyperlinkBug.pdf”));
pdf1.save(out);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}

If you delete the comments for adding the “B” segment, the document is saved.

Please advice,
Milan

Hello Milan,

I've tested the scenario and I'm able to notice that if the text segment is blank and we try to set the hyperlink to that blank segment, PDF is not generated. In your code you've created a blank segment "seg" and have assigned it an ID bmk1which is the destination for link. I'm not sure if Aspose.Pdf for Java architecture allows specifying hyperlink target to blank segments or not. I'll check it with our development team and will update you with the appropriate status.

We're sorry for your inconvenience.