Convert Project Data to PDF

This article shows how to render project data to PDF using Aspose.Tasks for Java. The API provides the following capabilities while rendering project data to various output formats including PDF.

PDF Creator Information

Saving a Project as a PDF

The Project class exposes the Save method which is used to save a project in various formats. The Save method allows you to render project data to PDF using the SaveFileFormat enumeration type.

To save a project to PDF:

  1. Load a Microsoft Project file.
  2. Save the project to PDF using SaveFileFormat.PDF.

The following lines of code show how to achieve this.

 1// For complete examples and data files, please go to
 2// The path to the documents directory.
 3String dataDir = Utils.getDataDir(SaveAsPdf.class);
 5// Read the input Project file
 6Project project = new Project(dataDir + "project6.mpp");
 7 + "Project5.pdf", SaveFileFormat.PDF);
10// Fitting contents to cell size
11Project project1 = new Project(dataDir + "project6.mpp");
12SaveOptions o = new PdfSaveOptions();
14// Set the LegendOnEachPage property to false to hide legends
16// Set the row height to fit cell content
19o.setPresentationFormat(PresentationFormat.TaskUsage);"result_months.pdf", o);
21o.setLegendOnEachPage(false); + "result_months_WithoutLegend.pdf", o);
24// Display result of conversion.
25System.out.println("Process completed Successfully");

Supported Graphical Column Indicators

Aspose.Tasks draw graphical column indicators while rendering project data to PDF. The following are the graphical indicators supported by Aspose.Tasks.

Indicator TypeGraphical Representation
Task Indicatorstask indicators list
Resource Indicatorsresource indicators list
Assignment Indicatorsassignment indicators list

Saving to Multiple PDF Files

To save the project data to multiple PDF files, set the SaveToSeparateFiles flag to true.

1// For complete examples and data files, please go to
2Project project2 = new Project("RenderMe.mpp");
3PdfSaveOptions saveOptions = new PdfSaveOptions();
5ArrayList<Integer> arl = new ArrayList<Integer>();
8saveOptions.getPages().add(4);"result.pdf", saveOptions);

Customizing TextStyle for Project Data

Aspose.Tasks allows you to customize the text style for overallocated resources. By default, the style for overallocated resources is similar to Microsoft Project (MSP), that is, it is red and bold. TextItemType.OverallocatedResources enables you to customize the color and style for overallocated resources. The example below shows how.

 1// For complete examples and data files, please go to
 2Project project3 = new Project("Advanced Assignments A_Start.mpp");
 3SaveOptions options = new PdfSaveOptions();
 6TextStyle style = new TextStyle();
11options.setTextStyles(new ArrayList<TextStyle>());
12options.getTextStyles().add(style);"temp.pdf", options);

Customizing Date Format

Aspose.Tasks give developers control over date formatting when rendering project data to output. The following example shows how to use the DateFormat enumerator to specify the date format.

 1Project project = new Project();
 2Date date = new Date();
 4// By default project.DateFormat == DateFormat.Date_ddd_mm_dd_yy (Mon 09/22/14)
 5// customize DateFormat (September 22, 2014)
 6project.setDateFormat(DateFormat.Date_mmmm_dd_yyyy);"saved.pdf", SaveFileFormat.PDF);
 8//Export to date format 19/07/2016
 9project.setDateFormat(DateFormat.DateDdMmYyyy);"p2.pdf", SaveFileFormat.PDF);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.