Strikethrough in DynamicJasper

1.6k views Asked by At

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!

1

There are 1 answers

0
janhink On BEST ANSWER

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.