Browse our Products

Aspose.Tasks for Java 21.6 Release Notes

All Changes

KeySummaryIssue Type
TASKSNET-4832Add an API to specify View object to render when saving project to PDF, HTML and Image formatsNew Feature
TASKSNET-4807Add support for rendering Left\Top\Inside\Bottom text labels for task bars in Gantt chartEnhancement
TASKSNET-4851Fix exception when trying to get Project using ProjectServerManagerBug
TASKSNET-4758Fix non-detailed general error message when trying to retrieve nonexistent project from Project OnlineBug
TASKSNET-4836Fix ArgumentException while reading XML without licenseBug
TASKSNET-4828Problem with .MPP file baseline1 Finish date on saving MPPBug
TASKSNET-4827Fix logic of RenderToSinglePage when project is saved to image formatBug
TASKSNET-4824Fix an exception when reading a project if no valid license loaded.Bug
TASKSNET-4834Fix reading of tasks from Primavera XML files.Bug
TASKSNET-4389Fix display of manual duration of task after project resaveBug
TASKSNET-3742Fix cost TD are not displayed in TaskUsage\ResourceUsage view when MPP file saved by Aspose.Tasks is opened by MS ProjectBug

Public API and Backwards Incompatible Changes

The following public types were added:Description
com.aspose.tasks.TaskBarTextConverterCustom converter of task’s data to bar text.
The following public methods and properties were added:Description
com.aspose.tasks.SaveOptions.ViewSettingsGets or sets a view () to render. You can use this options to explicitly specify which view should be saved to PDF, HTML or Image formats.
com.aspose.tasks.BarStyle.LeftBarTextConverterGets or sets user-defined converter to get text to render on the left of the task’s bar. Overrides the value of property.
com.aspose.tasks.BarStyle.TopBarTextConverterGets or sets user-defined converter to get text to render on the top of the task’s bar. Overrides the value of property.
com.aspose.tasks.BarStyle.RightBarTextConverterGets or sets user-defined converter to get text to render on the right of the task’s bar. Overrides the value of property.
com.aspose.tasks.BarStyle.BottomBarTextConverterGets or sets user-defined converter to get text to render on the bottom of the task’s bar. Overrides the value of property.
com.aspose.tasks.BarStyle.InsideBarTextConverterGets or sets user-defined converter to get text to render inside of the task’s bar. Overrides the value of property.
com.aspose.tasks.BarStyle.LeftFieldGets or sets a field to be displayed on the left of the bar.
com.aspose.tasks.BarStyle.TopFieldGets or sets a field to be displayed on the top of the bar.
com.aspose.tasks.BarStyle.RightFieldGets or sets a field to be displayed on the right of the bar.
com.aspose.tasks.BarStyle.BottomFieldGets or sets a field to be displayed on the bottom of the bar.
com.aspose.tasks.BarStyle.InsideFieldGets or sets a field to be displayed inside of the bar.
com.aspose.tasks.GanttBarStyle.LeftBarTextConverterGets or sets user-defined converter to get text to render on the left of the task’s bar. Overrides the value of property.
com.aspose.tasks.GanttBarStyle.TopBarTextConverterGets or sets user-defined converter to get text to render on the top of the task’s bar. Overrides the value of property.
com.aspose.tasks.GanttBarStyle.RightBarTextConverterGets or sets user-defined converter to get text to render on the right of the task’s bar. Overrides the value of property.
com.aspose.tasks.GanttBarStyle.BottomBarTextConverterGets or sets user-defined converter to get text to render on the bottom of the task’s bar. Overrides the value of property.
com.aspose.tasks.GanttBarStyle.InsideBarTextConverterGets or sets user-defined converter to get text to render inside of the task’s bar. Overrides the value of property.
The following public methods and properties were deleted:Description
com.aspose.tasks.TableField.ParentTable

Examples and additional notes

Related issue: TASKSNET-4832 - Add an API to specify View object to render when saving project to PDF, Html and Image formats.

Now you can specify the view to render explicitly. The feature can be useful when several views were defined for the same View screen in MPP project. For example there can be several Gantt chart views with different view options defined in MPP project file. Prior to v21.6:

Project project = new Project("TestViews.mpp");
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setPresentationFormat(PresentationFormat.ResourceSheet);
// If two resource sheet view are defined in TestViews.mpp, first was used.
project.save("output.pdf", saveOptions);

v21.6 and newer:

Project project = new Project("TestViews.mpp");
View view = project.getViews().stream()
    .filter(v -> "Customized Resource &Sheet".equals(v.getName()))
    .findFirst()
    .orElseThrow(IllegalStateException::new);
view.getPageInfo().getPageSettings().setPortrait(false);
PdfSaveOptions saveOptions = new PdfSaveOptions();
// view to render is specified explicitly, no need to set PresentationFormat.
saveOptions.setViewSettings(view);
project.save("output.pdf", saveOptions);
Related issue: TASKSNET-4807 - Add support for rendering Left\Top\Inside\Bottom text labels for task bars in Gantt chart.

Project project = new Project("TestGanttChartView.mpp");
GanttChartView ganttChartView = (GanttChartView) project.getViews().stream().filter(v -> "Gantt &Chart".equals(v.getName())).findFirst().orElseThrow(IllegalStateException::new);
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setTimescale(Timescale.DefinedInView);
saveOptions.setViewSettings(ganttChartView);

// Bar styles can be either task-specific (located in GanttChartView.CustomBarStyles)
// of category-specific (located in GanttChartView.BarStyles)

for (GanttBarStyle ganttBarStyle : ganttChartView.getCustomBarStyles()) {
    if (ganttBarStyle.getShowForTaskUid() != 11) {
        continue;
    }

    // For demonstration purposes we are modifying style for Task with Unique ID = 11
    ganttBarStyle.setLeftField(Field.TaskName);
    // Here we set custom converter to control which text should be rendered inside the task bar.
    ganttBarStyle.setInsideBarTextConverter(new TaskBarTextConverter() {
        @Override
        public String invoke(Task task) {
            return "Hours rem.: " + (long) (task.get(Tsk.REMAINING_WORK).getTimeSpan() / (1000 * 60 * 60));
        }
    });
}

for (GanttBarStyle ganttBarStyle : ganttChartView.getBarStyles()) {
    if (!ganttBarStyle.getShowForCategories().contains(GanttBarShowFor.Milestone)) {
        continue;
    }

    // For demonstration purposes we are modifying styles applicable to milestone tasks.

    ganttBarStyle.setRightField(Field.TaskActualFinish);
    ganttBarStyle.setTopBarTextConverter(new TaskBarTextConverter() {
        @Override
        public String invoke(Task task) {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(task.get(Tsk.ACTUAL_START));
            return Integer.toString(calendar.get(Calendar.DAY_OF_MONTH));
        }
    });
}

project.save("output.pdf", saveOptions);