Configure count of characters per row and rows per page to render

When processing text files you can adjust page parameters like max characters per line and max lines per page with MaxCharsPerRow and MaxRowsPerPage options that have been added in v21.11.

    try (Viewer viewer = new Viewer("sample.txt")) {
        HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
        viewOptions.getTextOptions().setMaxCharsPerRow(50); // Default value is 85
        viewOptions.getTextOptions().setMaxRowsPerPage(30); // Default value is 55


The following screenshot shows the difference when setting setMaxRowsPerPage(30).

Comparing output of default and adjusted value of MaxRowsPerPage parameter

More resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App

Along with full-featured Java library we provide simple but powerful free Apps. You are welcome to view Word, PDF, Excel, PowerPoint documents with free to use online GroupDocs Viewer App.