Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert Project File (MPP) to PDF Programmatically in Java
// Load input MPP file
Project project = new Project("project.mpp");
// Initilize SaveOptions class object
SaveOptions o = new PdfSaveOptions();
// Set the row height to fit cell content
o.setFitContent(true);
// Specify different properties
o.setTimescale(Timescale.Months);
o.setPresentationFormat(PresentationFormat.TaskUsage);
// Set the LegendOnEachPage property to false to hide legends
o.setLegendOnEachPage(false);
// Save output PDF document
project.save("result.pdf", o);
// Load input Project file
Project project = new Project(dataDir + "project.mpp");
// Initialize PdfEncryptionDetails class object
PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("test", "password", PdfEncryptionAlgorithm.RC4_128);
// Set permissions for output PDF file
encryptionDetails.setPermissions(PdfPermissions.None);
// Initialize PdfSaveOptions class object
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setTimescale(Timescale.Months);
saveOptions.setPresentationFormat(PresentationFormat.TaskUsage);
saveOptions.setEncryptionDetails(encryptionDetails);
// Save output PDF file
project.save(dataDir + "Password_output.pdf", saveOptions);
// Read the input Project file
Project project = new Project("Sample.mpp");
// Save the Project as PDF
project.save("Project.pdf", SaveFileFormat.PDF);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment