The color rendering is as expected with version 21.3, but not the filling: in the pdf rendering, there is a gradient (see pdf_result_NOK.png (14.3 KB)), but the expected result is a solid filling (expected_result.png (2.0 KB)).
We have three additional questions about PDF rendering :
How can we define gridelines on PDF rendering ?
For example, we want to display a black dashed line as in mpp_rendering_as_expected.png (39.5 KB) in MPP rendering.
How can we define barsâ text on PDF rendering ?
For example, we want to display the name in black on the left as in mpp_rendering_as_expected.png (39.5 KB) in MPP rendering.
How can we define timescale on PDF rendering ?
For example, we want to define âMonthâ timescale as in mpp_rendering_as_expected.png (39.5 KB) in MPP rendering.
Edit from antoinegentet : sorry, we found the solution for question 5 about TimeScale by adding "savePdfOptions.setTimescale(Timescale.DefinedInView);".
For above requirements, I have created a ticket with ID TASKSNET-4807 in our issue tracking system to evaluate the possibility of implementing them. This thread has been linked with the issue so that you may be notified once the issue will be fixed.
TASKSNET-4609 is being planned to Aspose.Tasks for .NET 21.7 which is to on July 2021. The estimation is preliminary and can be changed due to implementation complexity.
TASKSNET-4807 is being planned on Aspose.Tasks for .NET 21.5 (will be released in the first decade of May 2021).
The color rendering is as expected with version 21.3, but not
the filling: in the pdf rendering, there is a gradient (see pdf_result_NOK.png (14.3 KB)),
but the expected result is a solid filling (expected_result.png (2.0 KB)).
SaveOptions.UseGradientBrush property can be used to turn off gradient fill: You can use the following code works in Aspose.Tasks for Java 21.3:
Project mppProject = new Project("input.mpp");
PdfSaveOptions options = new PdfSaveOptions();
options.setUseGradientBrush(false);
options.setStartDate(mppProject.get(Prj.START_DATE));
options.setEndDate(mppProject.get(Prj.FINISH_DATE));
mppProject.save("output.pdf", options);
How can we define the rendering on max X pages vertically and max Y pages horizontally ?
For example, for a project of one month duration with a lot of tasks, I want to set max 1 page horizontally, and max 5 pages > vertically. Or for a long duration project with few tasks, I want to set max 2 pages vertically and max 6 pages horizontally.
The scale feature (Fit a project to X pages horizontally and Y pages vertically) is not supported, but is already in our backlog. When this support will be included, we will share the good news with you.
How can we define gridlines on PDF rendering ?
For example, we want to display a black dashed line as in mpp_rendering_as_expected.png (39.5 KB) in MPP rendering.
The following code can be used. It will work in latest Aspose.Tasks for Java 21.4 or upcomin 21.5 versions.
Project mppProject = new Project("pce_exported_projet.mpp");
PdfSaveOptions savePdfOptions = new PdfSaveOptions();
savePdfOptions.setTimescale(Timescale.DefinedInView);
savePdfOptions.setPresentationFormat(PresentationFormat.GanttChart);
savePdfOptions.setFitContent(true);
savePdfOptions.setStartDate(mppProject.get(Prj.START_DATE));
savePdfOptions.setEndDate(mppProject.get(Prj.FINISH_DATE));
GanttChartView view = null;
for(View v : mppProject.getViews())
{
if (v.getScreen() == ViewScreen.Gantt)
{
view = (GanttChartView)v;
}
}
Gridlines ganttRowGridline = null;
for (Gridlines g : view.getGridlines())
{
if (g.getType() == GridlineType.GanttRow)
{
ganttRowGridline = g;
}
}
// TODO : if ganttRowGridline is null, instantiate and add to view.getGridlines();
ganttRowGridline.setNormalPattern(LinePattern.Dashed);
ganttRowGridline.setNormalColor(Color.BLACK);
mppProject.save("output.pdf", savePdfOptions);
How can we define barsâ text on PDF rendering ?
For example, we want to display the name in black
on the left as in mpp_rendering_as_expected.png (39.5 KB) in MPP rendering.
The following code can be used. It will work in latest Aspose.Tasks for Java 21.4 or upcoming 21.5 versions.
Project mppProject = new Project("input");
PdfSaveOptions savePdfOptions = new PdfSaveOptions();
savePdfOptions.setTimescale(Timescale.DefinedInView);
savePdfOptions.setPresentationFormat(PresentationFormat.GanttChart);
savePdfOptions.setFitContent(true);
savePdfOptions.setStartDate(mppProject.get(Prj.START_DATE));
savePdfOptions.setEndDate(mppProject.get(Prj.FINISH_DATE));
GanttChartView view = null;
for(View v : mppProject.getViews())
{
if (v.getScreen() == ViewScreen.Gantt)
{
view = (GanttChartView)v;
}
}
for (GanttBarStyle ganttBarStyle : view.getCustomBarStyles())
{
// For example, we can change style for Task with Unique ID = 5
if (ganttBarStyle.getShowForTaskUid() == 5)
{
// Task's name will be rendered to the left of task's bar.
ganttBarStyle.setLeftField(Field.TaskName);
}
}
mppProject.save("output.pdf", savePdfOptions);
Thank you @mudassir.fayyaz for your help.
We tried versions 21.4 and 21.5 with your input.
We still canât display bar text or gridlines in PDF either with the code you mentioned as an example or within our project. However, the MPP version works very well.
Here is an example of the results we get, the PDF version should have the same gridlines and bar text as the MPP one :
The two pictures in my previous post should show the same view because they are exports from the same project.
Here are the pictures with highlighting of the bar text problem.
The gridlines speak for themselves : We have added are horizontal dotted lines. They appear in the MPP but there is nothing in the PDF.
Hello @mudassir.fayyaz. Do you have any update about the PDF view problem we discussed earlier? We still canât fix it on our end.
Do you have a resolution delay?
Can you please try using following sample code on your end and check if they are rendering (saving to PDF) the same view as the view Gantt bar styles were modified.
The following line could be added to the code snippet:
project.setDefaultView(view);
Project mppProject = new Project("input");
PdfSaveOptions savePdfOptions = new PdfSaveOptions();
savePdfOptions.setTimescale(Timescale.DefinedInView);
savePdfOptions.setFitContent(true);
savePdfOptions.setStartDate(mppProject.get(Prj.START_DATE));
savePdfOptions.setEndDate(mppProject.get(Prj.FINISH_DATE));
GanttChartView view = null;
for(View v : mppProject.getViews())
{
if (v.getScreen() == ViewScreen.Gantt)
{
view = (GanttChartView)v;
}
}
project.setDefaultView(view);
for (GanttBarStyle ganttBarStyle : view.getCustomBarStyles())
{
// For example, we can change style for Task with Unique ID = 5
if (ganttBarStyle.getShowForTaskUid() == 5)
{
// Task's name will be rendered to the left of task's bar.
ganttBarStyle.setLeftField(Field.TaskName);
}
}
mppProject.save("output.pdf", savePdfOptions);
Hello @mudassir.fayyaz, Thank you for you answer.
I can confirm that it is still not working right for us. The PDF shows no task name and no gridlines.