Merge MHT to PDF via C++
Sample code for concatenation MHT documents into single formats PDF on C++. Programmers can use this example code to placing MHT into PDF with VC++, GNU C++ in kinds of application.
Merge MHT to PDF Using C++
In order to merge MHT to PDF, we’ll use Aspose.PDF for C++ API which is a feature-rich, powerful and easy-to-use document manipulation and concatenation API for C++ platform. Open NuGet package manager, search for Aspose.PDF and install.
Package Manager Console Command
PM> Install-Package Aspose.PDF.Cpp
How to merge MHT to PDF via C++
C++ developers can easily load & merge MHT files to PDF in just a few lines of code.
<% ld-json %>
System Requirements
Aspose.PDF for C++is supported on all major operating systems. Just make sure that you have the following prerequisites.
- Microsoft Windows or a compatible OS with C++ Runtime Environment for Windows 32 bit, Windows 64 bit, and Linux 64 bit.
- Development environment like Microsoft Visual Studio.
- Aspose.PDF for C++ DLL referenced in your project.
This sample code shows MHT to PDF C++ concatenation
String pathSource1 = u"../../TestData/test.mht";
String pathSource2 = u"../../TestData/Second/test.mht";
// mht files can be parsed and loaded as Aspose Document
System::SharedPtr<Document> firstDoc = MakeObject<Document>(pathSource1, MakeObject<MhtLoadOptions>());
auto secondDoc = MakeObject<Document>(pathSource2, MakeObject<MhtLoadOptions>());
// create empty pdf document
auto outputDoc = MakeObject<Document>();
// set less memory usage with unload instead of fast performance
outputDoc->set_EnableObjectUnload(true);
for (auto const& page : firstDoc->get_Pages())
{
// add page from one document to another directly
outputDoc->get_Pages()->CopyPage(page);
}
for (auto const& page : secondDoc->get_Pages())
{
// add page from one document to another directly
outputDoc->get_Pages()->CopyPage(page);
}
// save result pdf to file
outputDoc->Save(u"Merger_mht_pdf.pdf", SaveFormat::Pdf);
Combine MHT to PDF in C++
Convert or combine multiple MHT into single PDF file in C++ is not straightforward task without using 3rd party library. This page shows how to merge multiple MHT files into a single PDF document using Aspose.PDF for C++. The example is written in Python but the API can be used in other programming languages. PDF files are merged such that the first one is joined at the end of the other document.
Package Manager Console Command
PM> Install-Package Aspose.PDF.Cpp