简体   繁体   中英

Strikethrough in DynamicJasper

is there a way how to apply the strikethrough style on a table cell using DynamicJasper? I only managed to 'hack' it by overriding JRPdfExporter and its method exportText where I add the style to the passed JRPrintText but there's got to be a proper way of doing it?

Here's my workaround if anyone is interested:

JRPdfExporter exporter = new JRPdfExporter()
{
    @Override
    public void exportText(JRPrintText text) throws DocumentException
    {
        if (text.getText().contains("<strike>"))
        {
            text.setText(text.getText().replaceAll("<strike>", ""));
            text.getStyle().setStrikeThrough(true);
        }
        super.exportText(text);
    }
};

What I do is that I mark the text which should have the strikethrough style with <strike> . Then I test if the text contains the mark and if it does, I apply the style and remove the mark.

But I believe there must be a legal way of doing it using DynamicJasper's API. Thanks!

Since I've got no answers and didn't find any other solution than migrating to DynamicReports, I'm marking the question as answered. DynamicReports is able to do it quite easily using conditional styling.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM