Skip to content

Instantly share code, notes, and snippets.

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/df85ab10987edad6def4555567c0ebb1 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/df85ab10987edad6def4555567c0ebb1 to your computer and use it in GitHub Desktop.
Read the complete article to converting PUB to Word document (DOC/DOCX) using C++ by visiting the following link.
https://blog.aspose.com/2021/07/28/convert-pub-to-word-document-doc-docx-using-cpp/
// Source PUB and output PDF file paths
System::String filePub = u"SourceDirectory\\1.pub";
System::String filePdf = u"OutputDirectory\\1.pdf";
// Load the PUB file
System::SharedPtr<IPubParser> parser = PubFactory::CreateParser(filePub);
System::SharedPtr<Aspose::Pub::Document> document = parser->Parse();
// Convert the PUB file to PDF
PubFactory::CreatePdfConverter()->ConvertToPdf(document, filePdf);
// Load the generated PDF file
auto pdfDocument = MakeObject<Aspose::Pdf::Document>(filePdf);
// Create an instance of the DocSaveOptions class
auto saveOptions = MakeObject<Aspose::Pdf::DocSaveOptions>();
// Set the format as DocX
saveOptions->set_Format(DocSaveOptions::DocFormat::DocX);
// Save the DocX file
pdfDocument->Save(u"OutputDirectory\\PubToDocx.docx", saveOptions);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment