Oracle Primavera P6 is a project, program and portfolio management software. It is used for planning, managing and executing large engineering projects. It uses the XER file format as a proprietary project file. The XER file supports all project, resource, and role information developed using the Primavera P6. In certain cases, we may need to convert the Primavera P6 project from the XER file to PDF programmatically. In this article, we will learn how to convert a Primavera XER file to a PDF in C#.
The following topics shall be covered in this article:
- What is Primavera XER File?
- C# XER to PDF Converter API
- Convert Primavera XER File to PDF
- Customize XER to PDF Conversion
What is Primavera XER File?
The XER is a proprietry format used in Primavera P6. An XER file is a text file and can easily be opened with any text editor. In Primavera, we can export multiple projects at once to a single XER file. The roles in the Primavera project can only be imported and exported using the XER format.
C# XER to PDF Converter API
To convert Primavera XER to a PDF file, we will be using the Aspose.Tasks for .NET API. It allows reading and writing the supported file formats without requiring Microsoft Project to be installed. Moreover, it allows converting and saving Primavera XER and P6XML files.
The Project class of the API represents a project. The Save(string, SaveFileFormat) method of this class saves the project data to the file. The SaveFileFormat defines enumeration for saving project format selection. We can specify additional options when rendering project pages to PDF using the PdfSaveOptions class.
Please either download the DLL of the API or install it using NuGet.
PM> Install-Package Aspose.Tasks
Convert Primavera XER File to PDF using C#
We can easily convert the Primavera P6 project from the XER file into a PDF by following the steps given below:
- Load the XER file using the Project class.
- Save as a PDF using the Save() method. It takes the output PDF file path and the SaveFileFormat as arguments.
The following sample code shows how to convert Primavera XER to PDF in C#.
Customize XER to PDF Conversion using C#
We can customize the conversion of XER to PDF using the PdfSaveOptoins class by following the steps given below:
- Firstly, load the XER file using the Project class.
- Next, create an instance of the PdfSaveOptions class.
- After that, define save options such as PageSize, etc.
- Finally, save the project as a PDF file using the Save() method. It takes the output PDF file path and the PdfSaveOptions as arguments.
The following sample code shows how to convert XER to PDF with customized settings in C#.
Get a Free License
You can get a free temporary license to try the library without evaluation limitations.
Conclusion
In this article, we have learned how to:
- load Primavera XER file;
- set PDF saving options;
- save the loaded XER as PDF in C#.
Besides converting XER to PDF in C#, you can learn more about Aspose.Tasks for .NET API using the documentation. In case of any ambiguity, please feel free to contact us at our free support forum.