HTML JPG PDF XML CGM
  Product Family
BMP

Merge MHT to PDF via Java

Sample code for concatenation MHT documents into single formats PDF on Java. Programmers can use this example code to placing MHT into PDF within any Web or Desktop Java based Application.

Merge MHT to PDF Using Java

In order to merge MHT to PDF, we’ll use Aspose.PDF for Java API which is a feature-rich, powerful, and easy to use concatenation API for Java platform. You can download its latest version directly from Maven and install it within your Maven-based project by adding the following configurations to the pom.xml.

Repository

<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>

Dependency

<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-pdf</artifactId>
<version>version of aspose-pdf API</version>
<classifier>jdk17</classifier>
</dependency>

How to merge MHT to PDF via Java

Java developers can easily load & merge MHT files to PDF in just a few lines of code.

<% ld-json %>

System Requirements

Aspose.PDF for Javais supported on all major operating systems. Just make sure that you have the following prerequisites.

  • Microsoft Windows or a compatible OS with Java Runtime Environment for JSP/JSF Application and Desktop Applications.
  • Development environment like Eclipse or IntelliJ IDEA.
  • Aspose.PDF for Java library referenced in your project.
 

This sample code shows MHT to PDF Java concatenation


	// create empty pdf document
	outputDoc = new com.aspose.pdf.Document();

	// mht files can be parsed and loaded as Aspose Document
	firstDoc = new com.aspose.pdf.Document("1.mht", new com.aspose.pdf.MhtLoadOptions());
	secondDoc = new com.aspose.pdf.Document("2.mht", new com.aspose.pdf.MhtLoadOptions());

	// add page from one document to another directly
	for (com.aspose.pdf.Page page : firstDoc.getPages())
		outputDoc.getPages().add(page);
	for (com.aspose.pdf.Page page : secondDoc.getPages())
		outputDoc.getPages().add(page);

	// save result pdf to file
outputDoc.save("Merger_mht_pdf.pdf", com.aspose.pdf.SaveFormat.Pdf);
 

Combine MHT to PDF in Java

Convert or combine multiple MHT into single PDF file in Java 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 Java. 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.

Repository

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
    </repository>
    

 

Dependency

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-pdf</artifactId>
    <version>version of aspose-pdf API</version>
    <classifier>jdk17</classifier>
    </dependency>
    

 

About Aspose.PDF for .NET API

A PDF Processing Library to create cross-platform applications with the ability to generate, modify, merge, render, secure and print documents without using Adobe Acrobat. It supports merging various file formats into PDF including HTML and merging PDF documents into various output formats. Developers can easily render all HTML content in a single Page PDF as well as merge HTML files with SVG graphic tags to Tagged PDF files. .NET PDF API offers compression, table creation, graph & image functions, hyperlinks, stamp and watermarking tasks, extended security controls & custom font handling.
  • Merge MHT to PDF via Online App