Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 23, 2021 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/23aa343d20cceae373dedb9319d43446 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/23aa343d20cceae373dedb9319d43446 to your computer and use it in GitHub Desktop.
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