Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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