Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created January 26, 2024 09:29
Show Gist options
  • Save aspose-com-gists/9cc3c996ef897913bfed6e7f63a2f284 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/9cc3c996ef897913bfed6e7f63a2f284 to your computer and use it in GitHub Desktop.
Convert Publisher to PowerPoint | PUB to PPT | PUB to PPTX
// This code example demonstrates how to convert Publisher file into PowerPoint presentation in C#.
string fileName = "Test.pub";
// Initialize a MemoryStream to hold output document
MemoryStream stream = new MemoryStream();
// Load input PUB file
IPubParser parser = PubFactory.CreateParser(fileName);
// Parse the input publisher file
Aspose.Pub.Document doc = parser.Parse();
// Convert the PUB file to PDF and save result in a MemoryStream
PubFactory.CreatePdfConverter().ConvertToPdf(doc, stream);
// Load input PDF file from the MemoryStream
Document document = new Document(stream);
// Initialize PptxSaveOptions class object
PptxSaveOptions options = new PptxSaveOptions();
// Save output presentation file (PPT/PPTX)
document.Save("Output.pptx", options);
// This code example demonstrates how to convert Publisher file into PowerPoint presentation in Java.
// Specify path for input Publisher file
String fileName = "Test.pub";
// Initialize ByteArrayOutputStream to hold intermediary PDF file.
final ByteArrayOutputStream os = new ByteArrayOutputStream();
// Initialize Pub Parser for the PUB file
IPubParser parser = PubFactory.createParser(fileName);
// Parse the Publisher file
com.aspose.pub.Document doc = parser.parse();
// Convert PUB to PDF file and save output into the stream
PubFactory.createPdfConverter().convertToPdf(doc, os);
// Load the intermediary PDF document
Document pdfDocument = new Document(os.toByteArray());
// Convert or Export the file to PPTX format
pdfDocument.save("Output.pptx", new PptxSaveOptions());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment