Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for Tooltip without Hyperlink #90

Open
subes opened this issue Oct 28, 2021 · 0 comments
Open

support for Tooltip without Hyperlink #90

subes opened this issue Oct 28, 2021 · 0 comments

Comments

@subes
Copy link

subes commented Oct 28, 2021

Most pdf viewers already support tooltips: https://gitlab.freedesktop.org/poppler/poppler/-/issues/34

Though with DynamicReports I can only use a workaround via hyperlinks:

   public ComponentBuilder<?, ?> getValue(final String name, final String value) {
        final TextFieldBuilder<String> nameCmp = DocumentReports.cmp.text(name + ":").setFixedWidth(nameWidth);
        if (tooltip != null) {
            final String tooltipAdj = newTooltipString(tooltip);
            nameCmp.setHyperLink(DocumentReports.hyperLink(tooltipAdj).setTooltip(tooltipAdj));
        }
        final TextFieldBuilder<String> valueCmp = DocumentReports.cmp.text(value).setFixedWidth(valueWidth);
        return DocumentReports.cmp.horizontalList(nameCmp, valueCmp);
    }

    public static String newTooltipString(final String tooltip) {
        //some characters break tooltips from working in pdfs
        return "-> " + Strings.stripNonPrintableAscii(Currencies.replaceCurrencySymbolsWithCurrencyCode(
                tooltip.replace(":", "_").replace(PercentScale.PERMILLE.getSymbol(), "permille")));
    }

Though this does not work well with evince, because it fails to show the tooltip from a broken hyperlink. (but one can copy the hyperlink address to read the tooltip with the above workaround). It works in Adobe Acrobat Reader, Foxit Reader and Okular for example. It does not work for pdf reader inside Firefox and Chrome. Also older versions of Adobe Acrobat Reader trimmed the hyperlink tooltips, so only half of it can be read.
Would there be a way to support direct tooltips (there seems to be a standardized \pdftooltip command)?
I also found this regarding JasperReports where it seems to be possible to set hyperlink targets (but variations of this disable tooltips on all pdf readers): https://stackoverflow.com/questions/10734834/tooltip-for-text-titles-headers-in-ireports
http://jasperreports.sourceforge.net/sample.reference/hyperlink/index.html#hyperlinks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant