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/646412e3cb84d611ef4cb124f9c683c6 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/646412e3cb84d611ef4cb124f9c683c6 to your computer and use it in GitHub Desktop.
Convert Word to PDF in C++
// Load the document from disk.
System::SharedPtr<Document> doc = System::MakeObject<Document>( u"Word.docx");
// Set the output PDF path
System::String outputPath = u"DOCX-to-PDF.pdf";
// Set PDF options
System::SharedPtr<PdfSaveOptions> options = System::MakeObject<PdfSaveOptions>();
// Set JPEG quality
options->set_JpegQuality(100);
// Save the document in PDF format
doc->Save(outputPath, options);
// Load the document from disk.
System::SharedPtr<Document> doc = System::MakeObject<Document>( u"Word.docx");
// Set the output PDF path
System::String outputPath = u"DOCX-to-PDF.pdf";
// Convert DOCX to PDF
doc->Save(outputPath);
std::cout << "Converted DOCX to PDF successfuly.";
// Load the document from disk.
System::SharedPtr<Document> doc = System::MakeObject<Document>( u"Word.docx");
// Set the output PDF path
System::String outputPath = u"DOCX-to-PDF.pdf";
// Set PDF options
System::SharedPtr<PdfSaveOptions> options = System::MakeObject<PdfSaveOptions>();
options->set_PageIndex(1);
options->set_PageCount(2);
// Save the document in PDF format.
doc->Save(outputPath, options);
// Load the document from disk.
System::SharedPtr<Document> doc = System::MakeObject<Document>( u"Word.docx");
// Set the output PDF path
System::String outputPath = u"DOCX-to-PDFA.pdf";
// Set PDF options
System::SharedPtr<PdfSaveOptions> options = System::MakeObject<PdfSaveOptions>();
options->set_Compliance(PdfCompliance::PdfA1a);
// Save the document in PDF format.
doc->Save(outputPath, options);
std::cout << "Converted DOCX to PDF/A successfuly.";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment