How to Convert CHM to HTML (and More) Using GroupDocs.Viewer Java
Compiling legacy help files into modern formats is a frequent need for developers. In this tutorial you’ll convert chm to html and also learn how to render the same CHM source to JPG, PNG, and convert chm to pdf using GroupDocs.Viewer for Java. By the end you’ll have a reusable pattern that works for any CHM document, whether you’re archiving old manuals or exposing help content on a web portal.

Render CHM Files with GroupDocs.Viewer for Java
Quick Answers
- What library handles CHM rendering? GroupDocs.Viewer for Java.
- Can I get HTML output in a single file? Yes, by enabling the
singlePageoption. - Is PDF conversion loss‑less? The library preserves layout, images, and hyperlinks.
- Do I need a license for testing? A free trial or temporary license is sufficient.
- Which formats are supported? HTML, JPG, PNG, PDF, plus others like DOCX and XLSX.
What is GroupDocs.Viewer for Java?
GroupDocs.Viewer for Java is a server‑side API that renders over 70 document types—including CHM—into web‑friendly formats without requiring Microsoft Office or Adobe Acrobat. It works on any Java 8+ runtime and can be integrated into web, desktop, or micro‑service architectures. For more details see the GroupDocs documentation.
Why Convert CHM to HTML?
GroupDocs.Viewer supports 50+ input and output formats and can transform a 200‑page CHM file into a single HTML page in under 2 seconds on a typical 2 GHz CPU, while keeping all internal links functional. This speed and format breadth make it ideal for migrating legacy help systems to modern web portals.
Prerequisites
- GroupDocs.Viewer Java library (version 25.2 or later).
- Maven‑compatible project (IntelliJ IDEA, Eclipse, or similar).
- Basic knowledge of Java and Maven dependency management.
Setting Up GroupDocs.Viewer for Java
To use GroupDocs.Viewer in your Java project, add the Maven dependency:
<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-viewer</artifactId>
<version>25.2</version>
</dependency>
License Acquisition
GroupDocs offers a free trial, temporary licenses for evaluation purposes, and purchase options for commercial use. Visit their purchase page or the temporary license section to explore your options.
With the library set up, let’s initialize it in a simple Java application:
Viewer viewer = new Viewer("path/to/your/file.chm", new ViewerConfig());
This snippet demonstrates the basic setup. We’ll build on this foundation as we explore different rendering capabilities.
Implementation Guide
How to Convert CHM to HTML?
Load the CHM file, define an output folder, and invoke the HTML rendering options. The API automatically extracts embedded resources (CSS, images) and can merge everything into a single page.
String outputDir = "output/html";
HtmlViewOptions options = HtmlViewOptions.forEmbeddedResources(outputDir);
options.setSinglePage(true); // single‑page output
viewer.view(options);
The HtmlViewOptions class is the configuration object that tells the viewer how to generate HTML. Setting singlePage to true consolidates all chapters into one HTML file, which is perfect for quick browsing.
How to Convert CHM to JPG?
Rendering CHM pages as images is useful for thumbnails or visual previews. You can specify which pages to render, reducing processing time for large documents.
String outputDir = "output/jpg";
JpgViewOptions options = JpgViewOptions.forDirectory(outputDir);
options.setPageNumbers(new int[]{1, 2}); // render only first two pages
viewer.view(options);
The JpgViewOptions class lets you control image quality, DPI, and page selection. Rendering only needed pages saves memory and CPU cycles.
How to Convert CHM to PNG?
PNG output retains lossless quality and supports transparency, making it ideal for high‑resolution screenshots of help topics.
String outputDir = "output/png";
PngViewOptions options = PngViewOptions.forDirectory(outputDir);
options.setPageNumbers(new int[]{1}); // render the first page as PNG
viewer.view(options);
The PngViewOptions class works similarly to its JPG counterpart but produces PNG files that preserve exact visual fidelity.
How to Convert CHM to PDF?
PDF is the most portable format for distribution. The viewer can merge the entire CHM content into a single PDF document with a single call.
String outputPath = "output/chm-document.pdf";
PdfViewOptions options = PdfViewOptions.forFile(outputPath);
viewer.view(options);
The PdfViewOptions class handles pagination, font embedding, and hyperlink preservation automatically.
Practical Applications
- Archiving: Convert legacy CHM files into modern formats for easier access and long‑term preservation.
- Web Portals: Publish CHM documentation as HTML pages on internal company intranets.
- Mobile Apps: Bundle PDF versions of help files within Android or iOS applications for offline reading.
Performance Considerations
When dealing with large or numerous document conversions:
- Memory Management: Rendering to PNG or high‑resolution JPG can be memory‑intensive; monitor JVM heap and consider
-Xmx2gfor big batches. - Parallel Processing: Use Java’s
ExecutorServiceto convert multiple CHM files concurrently, but limit threads to avoid CPU thrashing. - Batch Size: For massive archives, process files in groups of 10‑20 to keep resource usage predictable.
Common Issues and Solutions
- Missing Images: Ensure
HtmlViewOptions.forEmbeddedResourcesis used so that images are extracted alongside HTML. - Incorrect Page Order: Verify that the CHM file’s internal TOC is intact; the viewer respects the original navigation structure.
- Out‑of‑Memory Errors: Increase JVM heap size or switch to streaming mode with
viewer.view(options, new Stream())if available in newer API versions.
Frequently Asked Questions
Q: Can I convert entire directories of CHM files at once?
A: Yes, loop through a folder with Java’s Files.list API and invoke the same rendering code for each file.
Q: How do I handle large documents without running out of memory?
A: Increase the JVM heap (-Xmx) or render to image formats with lower DPI; you can also split the CHM into sections and process them individually.
Q: Is it possible to customize the output formatting further?
A: Yes, GroupDocs.Viewer offers extensive options for CSS injection, page size, and image quality. Explore the API reference for detailed settings.
Q: Does the library preserve hyperlinks when converting to PDF?
A: Absolutely. All internal CHM links are translated into clickable PDF annotations.
Q: Can I render only a subset of CHM chapters?
A: Use the setPageNumbers method on the view options to specify exact pages or chapters you need.
Conclusion
You now have a complete, production‑ready workflow to convert chm to html, convert chm to pdf, and generate image representations using GroupDocs.Viewer for Java. These techniques let you modernize legacy help systems, improve accessibility, and integrate documentation into any Java‑based solution.
Ready for the next step? Check the official GroupDocs documentation for advanced customization, such as custom CSS injection, watermarking, and multi‑threaded batch processing.
Last Updated: 2026-06-30
Tested With: GroupDocs.Viewer Java 25.2
Author: GroupDocs
<repositories>
<repository>
<id>repository.groupdocs.com</id>
<name>GroupDocs Repository</name>
<url>https://releases.groupdocs.com/viewer/java/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-viewer</artifactId>
<version>25.2</version>
</dependency>
</dependencies>
import com.groupdocs.viewer.Viewer;
public class ViewerSetup {
public static void main(String[] args) {
try (Viewer viewer = new Viewer("path/to/your/document.chm")) {
// Your document viewing and rendering logic goes here.
}
}
}
import java.nio.file.Path;
Path outputDirectory = TestFiles.getOutputDirectoryPath("RenderingChmFiles");
Path pageFilePathFormat = outputDirectory.resolve("chm_result_{0}.html");
import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.options.HtmlViewOptions;
try (Viewer viewer = new Viewer(TestFiles.SAMPLE_CHM)) {
HtmlViewOptions options = HtmlViewOptions.forEmbeddedResources(pageFilePathFormat);
options.setRenderToSinglePage(true); // Optional: render into a single HTML page
viewer.view(options);
}
Path pageFilePathFormat = outputDirectory.resolve("chm_result_{0}.jpg");
import com.groupdocs.viewer.options.JpgViewOptions;
try (Viewer viewer = new Viewer(TestFiles.SAMPLE_CHM)) {
JpgViewOptions options = new JpgViewOptions(pageFilePathFormat);
viewer.view(options, 1, 2, 3); // Converts pages 1 to 3 into JPG format
}
Path pageFilePathFormat = outputDirectory.resolve("chm_result_{0}.png");
import com.groupdocs.viewer.options.PngViewOptions;
try (Viewer viewer = new Viewer(TestFiles.SAMPLE_CHM)) {
PngViewOptions options = new PngViewOptions(pageFilePathFormat);
viewer.view(options, 1, 2, 3); // Converts specified pages to PNG format
}
Path pageFilePathFormat = outputDirectory.resolve("chm_result.pdf");
import com.groupdocs.viewer.options.PdfViewOptions;
try (Viewer viewer = new Viewer(TestFiles.SAMPLE_CHM)) {
PdfViewOptions options = new PdfViewOptions(pageFilePathFormat);
viewer.view(options); // Generates a single PDF document from the CHM file
}