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 HtmlViewOptions, JpgViewOptions, PngViewOptions 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:
- TimeUnit.UNSPECIFIED - The unknown, unspecified time scale
- TimeUnit.DAYS - The one day interval
- TimeUnit.THIRDS_OF_MONTHS - The one third of the month
- TimeUnit.MONTHS - The one month interval
The following are the steps to be followed to set time interval:
- Create HtmlViewOption / PngViewOptions / JpgViewOptions / PdfViewOptions object;
- Call getProjectManagementOptions() and set setTimeUnit(…) property;
- Call view(…) method.
The following code samples show how to render MS Project document by time intervals.
try (Viewer viewer = new Viewer("sample.mpp")) {
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
viewOptions.getProjectManagementOptions().setTimeUnit(TimeUnit.DAYS);
viewer.view(viewOptions);
}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
- GroupDocs.Viewer for Java examples, plugins, and showcase
- Document Viewer for .NET App WebForms UI Modern Example
- Document Viewer for Java App Dropwizard UI Modern Example
- Document Viewer for Java Spring UI Example
- GroupDocs.Viewer for .NET samples, plugins and showcase
- Document Viewer for .NET MVC UI Example
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.