Convert PST to HTML, JPG, PNG, PDF Using GroupDocs.Viewer for Java

Are you looking to convert pst to html or other formats like JPG, PNG, or PDF? With the powerful GroupDocs.Viewer for Java library, this task is straightforward and efficient. In this tutorial you’ll learn how to render Outlook PST/OST files into web‑friendly HTML, image files, or a single PDF, making your email archives easy to share and archive.

Convert PST/OST to HTML, JPG, PNG, PDF with GroupDocs.Viewer for Java

Convert PST/OST to HTML, JPG, PNG, PDF with GroupDocs.Viewer for Java

What You’ll Learn

  • How to set up GroupDocs.Viewer for Java in a Maven project.
  • Step‑by‑step instructions to java convert pst files to HTML, JPG, PNG, and PDF.
  • Configuration tips for optimal performance and common pitfalls.

Quick Answers

  • What library handles PST conversion? GroupDocs.Viewer for Java.
  • Can I convert PST to PDF directly? Yes, using PdfViewOptions.
  • Is a license required for production? A valid GroupDocs license is needed.
  • Which Java version is supported? JDK 8 or higher.
  • Do I need to extract attachments manually? No, the viewer renders them automatically.

What is GroupDocs.Viewer for Java?

GroupDocs.Viewer for Java is a server‑side API that loads over 100 document and email formats and renders them into HTML, image, or PDF output without external software. It processes PST files up to 2 GB while keeping memory usage under 200 MB.

How to convert pst to html using GroupDocs.Viewer for Java?

Load the PST file with new Viewer("source.pst"), configure HtmlViewOptions to point to an output folder, and call viewer.view(htmlOptions). The API extracts each email, preserves formatting, attachments, and metadata, and writes a separate HTML page per message—all in a single method call.

Why choose GroupDocs.Viewer?

  • High‑fidelity rendering – 99.9 % of email content (including rich‑text bodies, tables, and embedded images) is reproduced accurately.
  • Multiple output formats – One API call can generate HTML, JPG, PNG, or PDF, covering 50+ export options.
  • Zero external dependencies – No need for Outlook, Exchange Server, or third‑party converters; everything runs inside your Java runtime.

Prerequisites

  • GroupDocs.Viewer for Java – version 25.2 or later.
  • Java Development Kit (JDK) – 8 or newer.
  • Maven for dependency management.
  • Basic Java knowledge and familiarity with Maven.

Setting Up GroupDocs.Viewer for Java

Viewer is the core class in GroupDocs.Viewer for Java that loads a document and renders it into the chosen format. Add the GroupDocs repository and dependency to your pom.xml:

<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>

License Acquisition

  • Free trial – explore all features without cost.
  • Temporary license – extend evaluation time if needed.
  • Full license – required for production deployments.

Basic Initialization

Viewer instances are lightweight; you can reuse a single instance for many files to minimise object‑creation overhead.

import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.options.HtmlViewOptions;

public class PSTToHTML {
    public static void main(String[] args) {
        // Initialize Viewer with a sample PST file path
        try (Viewer viewer = new Viewer("YOUR_DOCUMENT_DIRECTORY/SAMPLE_PST")) {
            HtmlViewOptions options = HtmlViewOptions.forEmbeddedResources("output_directory/PST_result.html");
            viewer.view(options);
        }
    }
}

Implementation Guide

The following sections walk you through rendering PST/OST files into each supported format.

Rendering PST/OST Documents to HTML

Step 1: Set Up Output Directory

Define a folder where the HTML pages will be written. GroupDocs creates a sub‑folder for each email to keep assets organized.

Path outputDirectory = Paths.get("YOUR_OUTPUT_DIRECTORY");
Path pageFilePathFormat = outputDirectory.resolve("PST_result.html");

Step 2: Configure Load Options

LoadOptions lets you specify password handling, resource‑loading timeouts, and selective page rendering. Setting a timeout of 30 seconds works well for most server environments.

LoadOptions loadOptions = new LoadOptions();
loadOptions.setResourceLoadingTimeout(100);

Step 3: Define HTML View Options

HtmlViewOptions specifies the output folder, resource handling, and optional CSS settings for HTML conversion.

try (Viewer viewer = new Viewer("YOUR_DOCUMENT_DIRECTORY/SAMPLE_PST", loadOptions)) {
    HtmlViewOptions options = HtmlViewOptions.forEmbeddedResources(pageFilePathFormat);
    viewer.view(options);
}

Step 4: Initialize Viewer and Render HTML

Create a Viewer object, pass the PST file path, and call view with the HtmlViewOptions. The API automatically iterates through all messages inside the PST and generates a tidy HTML hierarchy.

try (Viewer viewer = new Viewer("YOUR_DOCUMENT_DIRECTORY/SAMPLE_PST", loadOptions)) {
    HtmlViewOptions options = HtmlViewOptions.forEmbeddedResources(pageFilePathFormat);
    viewer.view(options);
}

Rendering PST/OST Documents to JPG

Step 1: Set Up Output Directory

Create a dedicated folder for JPG snapshots; each email will become one or more image files depending on its length.

Path outputDirectory = Paths.get("YOUR_OUTPUT_DIRECTORY");
Path pageFilePathFormat = outputDirectory.resolve("PST_result_{0}.jpg");

Step 2: Configure Load Options

The same LoadOptions used for HTML can be reused here, ensuring consistent password handling across formats.

LoadOptions loadOptions = new LoadOptions();
loadOptions.setResourceLoadingTimeout(100);

Step 3: Define JPG View Options

JpgViewOptions controls image resolution, quality, and output folder for JPEG conversion.

try (Viewer viewer = new Viewer("YOUR_DOCUMENT_DIRECTORY/SAMPLE_PST", loadOptions)) {
    JpgViewOptions options = new JpgViewOptions(pageFilePathFormat);
    viewer.view(options);
}

Step 4: Initialize Viewer and Render JPG

Use viewer.view(jpgOptions) to generate high‑quality JPEG files ready for web preview.

try (Viewer viewer = new Viewer("YOUR_DOCUMENT_DIRECTORY/SAMPLE_PST", loadOptions)) {
    JpgViewOptions options = new JpgViewOptions(pageFilePathFormat);
    viewer.view(options);
}

Rendering PST/OST Documents to PNG

Step 1: Set Up Output Directory

PNG output is useful when you need lossless quality for archiving or OCR processing.

Path outputDirectory = Paths.get("YOUR_OUTPUT_DIRECTORY");
Path pageFilePathFormat = outputDirectory.resolve("PST_result_{0}.png");

Step 2: Configure Load Options

No additional settings are required beyond the password and timeout configuration.

LoadOptions loadOptions = new LoadOptions();
loadOptions.setResourceLoadingTimeout(100);

Step 3: Define PNG View Options

PngViewOptions allows you to set a transparent background and output folder for lossless PNG images.

try (Viewer viewer = new Viewer("YOUR_DOCUMENT_DIRECTORY/SAMPLE_PST", loadOptions)) {
    PngViewOptions options = new PngViewOptions(pageFilePathFormat);
    viewer.view(options);
}

Step 4: Initialize Viewer and Render PNG

Instantiate viewer.view(pngOptions) to produce PNG snapshots of each email.

try (Viewer viewer = new Viewer("YOUR_DOCUMENT_DIRECTORY/SAMPLE_PST", loadOptions)) {
    PngViewOptions options = new PngViewOptions(pageFilePathFormat);
    viewer.view(options);
}

Rendering PST/OST Documents to PDF

Step 1: Set Up Output Directory

A single PDF file per PST simplifies legal‑review workflows and reduces storage overhead.

Path outputDirectory = Paths.get("YOUR_OUTPUT_DIRECTORY");
Path pageFilePathFormat = outputDirectory.resolve("PST_result.pdf");

Step 2: Configure Load Options

When converting to PDF, you may want to enable setEmbedFonts(true) to guarantee visual fidelity on any machine.

LoadOptions loadOptions = new LoadOptions();
loadOptions.setResourceLoadingTimeout(100);

Step 3: Define PDF View Options

PdfViewOptions lets you choose compression level, embed fonts, and set the output file name for PDF conversion.

try (Viewer viewer = new Viewer("YOUR_DOCUMENT_DIRECTORY/SAMPLE_PST", loadOptions)) {
    PdfViewOptions options = new PdfViewOptions(pageFilePathFormat);
    viewer.view(options);
}

Step 4: Initialize Viewer and Render PDF

Create PdfViewOptions, optionally choose a compression level, and call viewer.view(pdfOptions). The API merges all emails into one searchable PDF document.

try (Viewer viewer = new Viewer("YOUR_DOCUMENT_DIRECTORY/SAMPLE_PST", loadOptions)) {
    PdfViewOptions options = new PdfViewOptions(pageFilePathFormat);
    viewer.view(options);
}

Practical Applications

  • Email Archiving: Turn large PST archives into searchable HTML or PDF for compliance.
  • Document Management Systems: Store converted files in systems that only accept PDF, PNG, or JPG.
  • Collaboration Platforms: Share converted emails as images in Slack or Teams.
  • Legal Review: Provide courts with PDF versions of email evidence.
  • Backup Strategies: Keep lightweight PNG or JPG snapshots of critical messages.

Performance Considerations

  • Resource Management: Reuse Viewer instances when processing multiple files to reduce overhead.
  • Memory Tuning: Adjust loadOptions.setResourceLoadingTimeout based on server capacity.
  • Asynchronous Processing: Offload conversion to background threads for responsive UIs.

Frequently Asked Questions

Q: How do I convert pst to pdf with the same code base?
A: Use PdfViewOptions as shown in the PDF rendering section; the rest of the code remains identical.

Q: Can GroupDocs.Viewer handle encrypted PST files?
A: Yes, provide the password via LoadOptions.setPassword("yourPassword") before rendering.

Q: What is the difference between java convert pst to PNG vs JPG?
A: PNG preserves lossless quality, ideal for screenshots, while JPG offers smaller file sizes for email previews.

Q: Is there a way to how to convert pst files in bulk?
A: Wrap the rendering logic in a loop that iterates over a directory of PST files; reuse the same Viewer configuration for each file.

Q: Does the API support converting PST files larger than 1 GB?
A: Yes, GroupDocs.Viewer streams data and can process files up to 2 GB without loading the entire archive into memory.

Conclusion

You now have a complete, production‑ready guide to convert pst to html, JPG, PNG, and PDF using GroupDocs.Viewer for Java. By following the steps above you can integrate email conversion into any Java‑based workflow, improve accessibility, and meet compliance requirements.


Last Updated: 2026-07-19
Tested With: GroupDocs.Viewer for Java 25.2
Author: GroupDocs