Working with Project Pages

Aspose.Tasks for Java 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.

Getting number of pages in a 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 Java:

1// For complete examples and data files, please go to
2Project project = new Project(projectName);
3// Get number of pages
4int iPages = project.getPageCount();
5// Get number of pages (Timescale.Months)
6iPages = project.getPageCount(0, Timescale.Months);
7// Get number of pages (Timescale.ThirdsOfMonths)
8iPages = project.getPageCount(0, Timescale.ThirdsOfMonths);

Programming Sample: Get Number of Pages for Different Views Aspose.Tasks for Java 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.

 1// For complete examples and data files, please go to
 2// Read the source Project
 3Project project = new Project(projectName);
 4// Get number of pages
 6        .println("Number of Pages = " + project.getPageCount(PresentationFormat.ResourceUsage, Timescale.Days));
 7// Get number of pages (Months)
 9        "Number of Pages = " + project.getPageCount(PresentationFormat.ResourceUsage, Timescale.Months));
10// Get number of pages (ThirdsOfMonths)
11System.out.println("Number of Pages = "
12        + project.getPageCount(PresentationFormat.ResourceUsage, Timescale.ThirdsOfMonths));

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

 1Project project = new Project(projectName);
 3Date dtStartDate, dtEndDate;
 4java.util.Calendar cal = java.util.Calendar.getInstance();
 6cal.add(java.util.Calendar.DAY_OF_MONTH, 7);    //add 7 days from start of project
 7dtStartDate = cal.getTime();
 9//Get Finish date with 30 days offset
11cal.add(java.util.Calendar.DAY_OF_MONTH, -30);
12dtEndDate = cal.getTime();
14ImageSaveOptions options = new ImageSaveOptions(SaveFileFormat.PNG);
16    options.setSaveToSeparateFiles(true);
17    options.setPageSize(PageSize.A3);
18    options.setTimescale(Timescale.Months);
19    options.setStartDate (dtStartDate);
20    options.setEndDate(dtEndDate);
23int pageCount = project.getPageCount_PageSize(
24    PageSize.A3,
25    Timescale.Months,
26    dtStartDate,
27    dtEndDate);
29System.out.println("Number of Pages = " + pageCount);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.