views:

106

answers:

2

What functionality in iReport allows for tool tip text?

I have a field name description that contains very large text. Instead of displaying large text I want to show two or three lines and rest of text as a tool tip. How is this possible?

A: 

That should be possible if you are exporting your report to HTML, or viewing it in JasperViewer.

medopal
A: 

There are two ways:

From the page:

The pushButtons must have a unique name, such as the hash of the chunk to create a unique name. I'm using HYPERLINK_TYPE_NONE, so I don't have to change the reference type.

Is the following code:

public class StudentPdfExporter extends JRPdfExporter {
  @Override protected void setHyperlinkInfo(Chunk chunk, JRPrintHyperlink link) {
    switch (link.getHyperlinkType()) {
      case JRHyperlink.HYPERLINK_TYPE_NONE: {
        if (link.getHyperlinkTooltip() != null) {
           PdfFormField pushButton = PdfFormField.createPushButton(pdfWriter);
           pushButton.setFieldName(String.format("tooltip%s", chunk.hashCode()));
           Rectangle rect = new Rectangle(0, 0, 0, 0);
           pushButton.setWidget(rect, PdfAnnotation.HIGHLIGHT_NONE);
           pushButton.put(PdfName.TU, new PdfString(link.getHyperlinkTooltip(), PdfObject.TEXT_UNICODE));
           chunk.setAnnotation(pushButton);
        }
        break;
      }

      default: {
        super.setHyperlinkInfo(chunk, link);
        break;
      }
    }
  }
}

I do not know why a switch statement is being used over if and else.

I also have not tested the code.

Dave Jarvis