Aspose.Task save to PDF rendering issue

Hi @mudassir.fayyaz

Thank you for the update.

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)).

Thanks for your help.

We have three additional questions about PDF rendering :

  1. 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.

  2. 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.

  3. 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.

Here you can find expected result in MPP print preview (mpp_rendering_as_expected.png (39.5 KB)) and result not as expected in PDF rendering (pdf_rendering_nok.png (60.2 KB)).

Thanks for your support.

Edit from antoinegentet : sorry, we found the solution for question 5 about TimeScale by adding "savePdfOptions.setTimescale(Timescale.DefinedInView);".

I have shared feedback in our issue tracking system concerning to this.

@mudassir.fayyaz,

Thanks! Keep me posted.
Have a good day.

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.

1 Like

@mudassir.fayyaz, thank you for that.

Can you give me update about both TASKNET-4609 and TASKNET-4807 ?
Do you have a resolution delay ?

Best regards.
Antoine.

@antoinegentet

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).

@antoinegentet

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);

@antoinegentet

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.

@antoinegentet

  1. 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);

@antoinegentet

  1. 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);

The issues you have found earlier (filed as TASKSNET-4807) have been fixed in this update.

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 :

We expect the same output in PDF as in MPP because we build the project in the exact same way, only the project’s saving is different.

Best regards,
TĂ©o

@teo.schaffner

Can you please highlight the issue by showing comparison of two outputs that I may add in our issue tracking system.

@mudassir.fayyaz

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.

mpp-screenshot-highlight.jpg (304.6 KB)
pdf-screenshot-highlight.jpg (247.2 KB)

Best regards,
TĂ©o

@teo.schaffner

I have updated the feedback shared by you in our issue tracking system and we will get back to you with feedback as soon as possible.

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?

@teo.schaffner

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.

@teo.schaffner

Can you please share the output that you have obtained so that I may add that in our issue tracking system to investigate it further.