在jasper中,我使用锚的和hyperlinkTooltipExpression
示例代码:
<textField hyperlinkType="LocalAnchor">
<reportElement x="267" y="94" width="100" height="30" uuid="8fa9ce3d-015c-4d13-a677-3b9dbea4c222"/>
<textFieldExpression><![CDATA["Anchor Target"]]></textFieldExpression>
<hyperlinkAnchorExpression><![CDATA["expert"]]></hyperlinkAnchorExpression>
<hyperlinkTooltipExpression><![CDATA["expert"]]></hyperlinkTooltipExpression>
</textField>这适用于IDE预览,但如果导出到PDF中,工具提示的工具提示没有显示在Adobe中,在文档查看器(linux)中显示,而是用es显示。“转到x页”
发布于 2016-01-04 12:06:07
在jasper中,我找不到任何支持在超级链接( JasperReport源代码 )上生成工具提示。
但是,您可以在手动生成注释的setHyperlinkInfo上重写JRPdfExporter。
关于如何在LocalAnchor上生成工具提示的示例
JRPdfExporter exporter = new JRPdfExporter() {
@Override
protected void setHyperlinkInfo(Chunk chunk, JRPrintHyperlink link) {
if (link!=null && link.getHyperlinkTooltip() != null && HyperlinkTypeEnum.LOCAL_ANCHOR.equals(link.getHyperlinkTypeValue())) {
PdfFormField pushButton = PdfFormField.createPushButton(pdfWriter);
pushButton.setFieldName(String.format("tt%s", chunk.hashCode()));//Need's unique name if multiple
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);
if (link.getHyperlinkAnchor() != null){
pushButton.setAction(PdfAction.gotoLocalPage(link.getHyperlinkAnchor(), false));
}
return;
}
super.setHyperlinkInfo(chunk, link);
}
};若要在其他类型的hyperlinkType (Reference,Remote )上生成工具提示,请继续类似的实现。
https://stackoverflow.com/questions/34590151
复制相似问题