Working with Project Pages

[ Hide Show ]

Aspose.Tasks for .NET can retrieve the total number of pages in a project. The GetPageCount method offered by Aspose.Tasks.Visualization namespace returns the total page count in a project with options of rendering them based on Timescale.Days, Timescale.Months or Timescale.ThirdsOfMonths.

Get Number of Pages in Project

The Project class exposes the GetPageCount method which is used to get the number of total pages in a project. The total count of pages in a project can be retrieved for Timescale.Days, Timescale.Months or Timescale.ThirdsOfMonths.

To save a project to PDF:

  1. Load a Microsoft Project file.
  2. Get the project’s total page count using the GetPageCount method with optional timescale settings.

Programming Sample: Get Number of Pages in Project The following lines of code shows how to achieve this using C#.

1Project project = new Project("New Project.mpp");
3// Get number of pages,  Timescale.Months, Timescale.ThirdsOfMonths
4int iPages = project.GetPageCount();
5iPages = project.GetPageCount(Timescale.Months);
6iPages = project.GetPageCount(Timescale.ThirdsOfMonths);

Programming Sample: Get the number of pages for different Views Aspose.Tasks for .NET supports rendering a project’s resource usage, resource sheet and task usage to PDF format, and enables users to get the number of pages in the rendered output for these views. This programming sample demonstrates rendering a projects’ usage view and getting the number of pages in the rendered output.

1Project project = new Project("New Project.mpp");
3// Get number of pages,  Months and  ThirdsOfMonths
4Console.WriteLine(string.Format("Number of Pages = '{0}'", project.GetPageCount(PresentationFormat.ResourceUsage, Timescale.Days)));
5Console.WriteLine(string.Format("Number of Pages = '{0}'", project.GetPageCount(PresentationFormat.ResourceUsage, Timescale.Months)));
6Console.WriteLine(string.Format("Number of Pages = '{0}'", project.GetPageCount(PresentationFormat.ResourceUsage, Timescale.ThirdsOfMonths)));

Programming Sample: Get number of pages based on Start and End Dates

 1Project project = new Project("New Project.mpp");
 3ImageSaveOptions options = new ImageSaveOptions(SaveFileFormat.PNG)
 5    SaveToSeparateFiles = true,
 6    PageSize = PageSize.A3,
 7    Timescale = Timescale.Months,
 8    StartDate = project.Get(Prj.StartDate) - TimeSpan.FromDays(10),
 9    EndDate = project.Get(Prj.FinishDate) + TimeSpan.FromDays(30)
11int pageCount = project.GetPageCount(
12    PageSize.A3,
13    Timescale.Months,
14    project.Get(Prj.StartDate) - TimeSpan.FromDays(10),
15    project.Get(Prj.FinishDate) + TimeSpan.FromDays(30));

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.