Search code examples
birt

How do I wrap data in BIRT?


I have developed a BIRT report and need to export the output as PDF and as an Excel Spreadsheet. I am looking a solution to wrap data in PDF report exported from BIRT. A text gets truncated in the PDF, if it does not have spaces as soon as it exceeds the available width of the column. e.g. phone number getting truncated I would like to know if there is a solution without the need for adding a custom code as provided in How to wrap column data in birt report. This solution adds whitespace to the data which is not desirable when the report is exported to an excel spreadsheet. In essence, this solution manipulates the data which isn't the right thing to do.

I have tried using the Whitespace auto option but that does not work.

I am using BIRT version 4.12.


Solution

  • I was able to figure out the solution for getting the text wrapped in the PDF export. Made use of IPDFRenderOption.PDF_WORDBREAK for the same.

        PDFRenderOption pdfOptions = new PDFRenderOption();
        pdfOptions.setOutputFileName("T:/temp/filename.pdf");
        pdfOptions.setOutputFormat("pdf");
        pdfOptions.setOption(IPDFRenderOption.PDF_WORDBREAK, true);
        task.setRenderOption(pdfOptions);
        task.run();