Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 23, 2021 06:55
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/920d26296d6511da9bf9ef8b503341f7 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/920d26296d6511da9bf9ef8b503341f7 to your computer and use it in GitHub Desktop.
Convert MPP File to PDF Programmatically using C# .NET | Microsoft Project File Conversion
// Load input MPP (Microsoft Project) file
Project project = new Project("New Project.mpp");
// Initialize PdfSaveOptions class object
PdfSaveOptions options = new PdfSaveOptions();
// Set SaveToSeparateFiles to true
options.SaveToSeparateFiles = true;
// Specify the page numbers
options.Pages = new List<int>();
options.Pages.Add(1);
options.Pages.Add(4);
// Save output PDF file
project.Save("SaveToMultiplePDFFiles_out.pdf", (SaveOptions)options);
// Load input (MPP) Project file
Project project = new Project("project.mpp");
// Initialize PdfEncryptionDetails class object
PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("test", "password", PdfEncryptionAlgorithm.RC4_128);
// Set permissions for output PDF file
encryptionDetails.Permissions = PdfPermissions.None;
// Initialize PdfSaveOptions class object
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.Timescale = Timescale.Months;
saveOptions.PresentationFormat = PresentationFormat.TaskUsage;
saveOptions.EncryptionDetails = encryptionDetails;
// Save output PDF file
project.Save("Password_output.pdf", saveOptions);
// Load input Project file (MPP)
Project project = new Project(dataDir + "project.mpp");
// Save output PDF file
project.Save("SaveProjectAsPDF_out.pdf", SaveFileFormat.PDF);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment