Free Support Forum - aspose.com

Inconsistencies between saved project and generated pdf

When generating a pdf of a project file, not all of the project lines are displaying in the generated pdf. I am just using project.Save(stream,SaveFileFormat.PDF).

@davno,

I have observed the information shared by you and request you to please share the source code and Project file along with generated PDF for reference. Please first try using latest Aspose.Tasks for .NET 19.7 on your end as well.

Aspose.Tasks_19.7.zip (204.9 KB)

The .zip contains the same project file saved in 2 different states as well as the generated pdf’s. There are lines missing in the pdf for both.

Code used was just a basic save to pdf:

    private void CreateTestPdf(string sourcePath, string targetPath)
    {
		EnsureLicense();
        var project = new Project(sourcePath);
        project.Save(targetPath, SaveFileFormat.PDF);
    }

@davno,

I have observed the issue shared by you. An issue with ID TASKSNET-3425 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Hello @davno.

The task “Task5” is collapsed in project “Project3.1.mpp”, so it’s children are not visible in the resulting PDF.
Thus Aspose.Tasks mimics the behavior of MS Project application which doesn’t print such tasks.

Hi @vasiliysinitsyn
I am not referring to Task 5 being collapsed in one file and expanded in the other file. I am referring to the differences in the renditions as to when the file is opened in MS Project. In these 2 samples there are missing lines (Task 10 and Task 12).
I have attached screen shots showing the pdf rendition and the file opened in MS Project.

project.3.mpp.png (174.7 KB)

project.3.1.mpp.png (130.1 KB)

@davno,

I have updated the information in our issue tracking system and will share the feedback with you as soon as it will be shared. We request for your patience in this regard.

@davno,

We have investigated the issue further on our end. Actually, the attached projects have their TimescaleStart and TimescaleFinish set to 22.07.2019 23.08.2019 0:00:00, so tasks with start\finish outside of this range are skipped. You can render the full project using the following code:

Project project = new Project("Project3.mpp");         
project.Set(Prj.TimescaleStart, DateTime.MinValue);
project.Set(Prj.TimescaleFinish, DateTime.MinValue);            
project.Save("Project3.pdf", SaveFileFormat.PDF);

or by setting the exact dates to render:

Project project2 = new Project(@"Project3.mpp");

var pdfSaveOptions = new PdfSaveOptions()
{                StartDate = new DateTime(2019, 7, 29),                
                 EndDate = new DateTime(2019, 11, 1)           
 };

project2.Save(@"Project3.2.pdf", pdfSaveOptions);

I hope the shared information will be helpful.

Hi @mudassir.fayyaz
Thanks for the reply and further information.
Unfortunately that still doesn’t give me the result I want which is to render the document so it appears the same as when opened using MS Project.

If I change the Timescale dates to MinValue, the spreadsheet part of the project file displays correctly, but then the timeline part of the file displays incorrectly. It displays the full project timeline, not the timeline that is displayed in MS Project. I have included the various different presentation formats that I have tried in the attached zip.

msproject.renditions.zip (653.8 KB)

@davno,

Thank you for your feedback. I have associated the information in our issue tracking system and will share the good news with you as soon as the issue will be addressed.

@davno,

I like to share that in upcoming Aspose.Tasks for .NET 19.11, we have included support where you can now specify a callback and customize list of rendered tasks in Gantt, Task Usage and Task Sheet views.


            Project project = new Project("test.mpp");

            SaveOptions options = new PdfSaveOptions
            {
                Project = project,
                TasksFilter = new CustomTasksFilter()
            };

            private class CustomTasksFilter : ICondition<Task>
            {
                        public bool Check(Task el)
                        {
                            return el.Get(Tsk.IsSummary) == true || el.Get(Tsk.Duration).TimeSpan > TimeSpan.Zero;
                        }
            }

We will share notification with you once Aspose.Tasks for 19.11 will be available.

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

Hi @mudassir.fayyaz
I have taken version 19.11 and implemented as specified above and it is almost correct now.
In my file it is excluding every line that has 0 days duration.

mpp.sent.to.aspose.zip (99.5 KB)

Just noticed your sample has condition
el.Get(Tsk.Duration).TimeSpan > TimeSpan.Zero

Is there any problem with changing it to
el.Get(Tsk.Duration).TimeSpan >= TimeSpan.Zero

to include 0 day rows?

Ignore this, Duration is not required for display.

@davno,

You may consider altering the if condition to include 0 in it and may observe the difference in results. If that suffice your requirements that will be good. Otherwise, you may share further with us.

Hi @mudassir.fayyaz
I ended up with the following to get the pdf to display as the file opens in Project:

  1. If outlinelevel = 1 always return true
  2. For all other levels if the parent level is not expanded I set the expanded property for the task to false. This gets me the correct display for nested tasks.

@davno,

It’s good to know things are as expected on your end. Actually, the condition

return el.Get(Tsk.IsSummary) == true || el.Get(Tsk.Duration).TimeSpan > TimeSpan.Zero;

is just for demonstration purposes.

There is no problem to implement the Check method in the following way to include all tasks:

                    public bool Check(Task el)
                    {
                        return true;
                    }