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 (or JpgViewOptions, or 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:
- Unknown - The unknown, unspecified time scale
- Days - The one day interval
- ThirdsOfMonths - The one third of the month
- Months - The one month interval
The following are the steps to be followed to set time interval:
- Create HtmlViewOption / PngViewOptions / JpgViewOptions / PdfViewOptions object;
- Set ProjectManagementOptions.TimeUnit property;
- Call View method.
The following code samples show how to render MS Project document by time intervals.
using (Viewer viewer = new Viewer("sample.mpp"))
{
HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources();
viewOptions.ProjectManagementOptions.TimeUnit = TimeUnit.Days;
viewer.View(viewOptions);
}
More resources
View MS Project Files Online
Along with full-featured .NET library we provide simple but powerful free online Apps. View MS Project MPP, MPT, and MPX files online with GroupDocs Viewer App.
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
- GroupDocs.Viewer for .NET examples, plugins, and showcase
- GroupDocs.Viewer for Java examples, plugins, and showcase
- Document Viewer for .NET MVC UI Example
- 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