Adjust time unit

When rendering MS Project documents GroupDocs.Viewer tries to find optimal output size and time unit depending on the project’s overall length. In case you need to set your own page size or time unit, you can set ProjectManagementOptions class properties of corresponding HtmlViewOptionsJpgViewOptionsPngViewOptions or PdfViewOptions class as shown in code samples below. Time unit refers to the smallest unit (days, third of a month or month) used in timescale bar. When the TimeUnit.DAYS is selected, you will get the most detailed view of your tasks. Whereas, when TimeUnit.MONTH is selected, you will get the more general representation of tasks.

The TimeUnit enumeration contains the following members:

The following are the steps to be followed to set time interval:

The following code samples show how to render MS Project document by time intervals.

    Viewer viewer = new Viewer("sample.mpp");
    HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
    viewOptions.getProjectManagementOptions().setTimeUnit(TimeUnit.DAYS);
    viewer.view(viewOptions);
    viewer.close();

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.