For more details, please visit Convert PUB to Word Document DOC or DOCX Programmatically in Java
Last active
December 23, 2021 06:12
-
-
Save aspose-com-gists/1e9e2f83bba549ef6e134c5cfd4c12c4 to your computer and use it in GitHub Desktop.
Convert or Export MS Publisher PUB File to Word Document DOC or DOCX Programmatically in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Specify path for input Publisher file | |
String fileName = "Sample.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 MS Word DOCX or DOC format | |
pdfDocument.save("PUBToDOCX.docx", SaveFormat.DocX); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment