# Render Outlook data files as HTML, PDF, and image files This topic describes how to use the GroupDocs.Viewer Node.js API to convert Outlook data files (PST and OST) to HTML, PDF, PNG, and JPEG formats. [GroupDocs.Viewer for Node.js via Java](https://products.groupdocs.com/viewer/nodejs-java) allows you to render Microsoft Outlook data files in HTML, PDF, PNG, and JPEG formats. Use this library to display the contents of OST and PST files within your Node.js application (web or desktop). To start with the GroupDocs.Viewer API, create a [Viewer](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer/viewer) class instance. Pass a document you want to view to the class constructor. You can load the document from a file or stream. Call one of the [Viewer.view](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer/viewer/) method overloads to convert the document to HTML, PDF, or image format. These methods allow you to render the entire document or specific pages. {{< button style="primary" link="https://products.groupdocs.app/viewer/outlook" >}} {{< icon "gdoc_person" >}} View Outlook files online {{< /button >}} {{< button style="primary" link="https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Node.js-via-Java" >}} {{< icon "gdoc_github" >}} View demos and examples on GitHub {{< /button >}} ## Supported Outlook data file formats GroupDocs.Viewer supports the following Outlook data file formats: * [Outlook Offline Storage Table](https://docs.fileformat.com/email/ost) (.OST) * [Outlook Personal Storage Table](https://docs.fileformat.com/email/pst) (.PST) ## Render Outlook data files as HTML To convert an OST or PST file to HTML, call the [HtmlViewOptions.forEmbeddedResources](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/htmlviewoptions/#forEmbeddedResources--) method to create an [HtmlViewOptions](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/htmlviewoptions) class instance and pass this instance to the [Viewer.view](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer/viewer/) method. {{< tabs "render-pst-to-html">}} {{< tab "JavaScript" >}} ```js import { Viewer, HtmlViewOptions } from '@groupdocs/groupdocs.viewer'; const viewer = new Viewer("sample.pst") // Specify the HTML file name. const viewOptions = HtmlViewOptions.forEmbeddedResources("render-pst-to-html/pst-to-html.html") viewer.view(viewOptions) ``` {{< /tab >}} {{< tab "sample.pst" >}} {{< tab-text >}} `sample.pst` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/nodejs-java/_sample_files/rendering-basics/render-outlook-data-files/sample.pst) to download it. {{< /tab-text >}} {{< /tab >}} {{< /tabs >}} The following image demonstrates the result: ![Render a PST file to HTML](https://docs.groupdocs.com/viewer/nodejs-java/images/rendering-basics/render-outlook-files/render-pst-to-html.png) ## Render Outlook data files as PDF Create a [PdfViewOptions](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/pdfviewoptions) class instance and pass it to the [Viewer.view](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer/viewer/) method to convert an OST or PST file to PDF. The `PdfViewOptions` class properties allow you to control the conversion process. For instance, you can protect the output PDF file, reorder its pages, and specify the quality of document images. Refer to the following documentation section for details: [Rendering to PDF]({{< ref "viewer/nodejs-java/developer-guide/rendering-documents/rendering-to-pdf/_index.md" >}}). {{< tabs "render-pst-to-pdf">}} {{< tab "JavaScript" >}} ```js import { Viewer, PdfViewOptions } from '@groupdocs/groupdocs.viewer'; const viewer = new Viewer("sample.pst") // Create a PDF file. const viewOptions = PdfViewOptions("render-pst-to-pdf/pst-to-pdf.pdf") viewer.view(viewOptions) ``` {{< /tab >}} {{< tab "sample.pst" >}} {{< tab-text >}} `sample.pst` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/nodejs-java/_sample_files/rendering-basics/render-outlook-data-files/sample.pst) to download it. {{< /tab-text >}} {{< /tab >}} {{< /tabs >}} The following image demonstrates the result: ![Render a PST file to PDF](https://docs.groupdocs.com/viewer/nodejs-java/images/rendering-basics/render-outlook-files/render-pst-to-pdf.png) ## Render Outlook data files as PNG Create a [PngViewOptions](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/pngviewoptions) class instance and pass it to the [Viewer.view](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer/viewer/) method to convert an OST or PST file to PNG. Use the [PngViewOptions.setHeight](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/pngviewoptions/#setHeight-int-) and [PngViewOptions.setWidth](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/pngviewoptions/#setWidth-int-) methods to specify the output image size in pixels. {{< tabs "render-pst-to-png">}} {{< tab "JavaScript" >}} ```js import { Viewer, PngViewOptions } from '@groupdocs/groupdocs.viewer'; const viewer = new Viewer("sample.pst") // Convert the PST file to PNG. // {0} is replaced with the page numbers in the output image names. const viewOptions = PngViewOptions("render-pst-to-png/pst-to-png-page_{0}.png") // Set width and height. viewOptions.setWidth(950) viewOptions.setHeight(550) viewer.view(viewOptions) ``` {{< /tab >}} {{< tab "sample.pst" >}} {{< tab-text >}} `sample.pst` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/nodejs-java/_sample_files/rendering-basics/render-outlook-data-files/sample.pst) to download it. {{< /tab-text >}} {{< /tab >}} {{< /tabs >}} The following image demonstrates the result: ![Render a PST file to PNG](https://docs.groupdocs.com/viewer/nodejs-java/images/rendering-basics/render-outlook-files/render-pst-to-png.png) ## Render Outlook data files as JPEG Create a [JpgViewOptions](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/jpgviewoptions) class instance and pass it to the [Viewer.view](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer/viewer/) method to convert an OST or PST file to JPEG. Use the [JpgViewOptions.setHeight](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/jpgviewoptions/#setHeight-int-) and [JpgViewOptions.setWidth](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/jpgviewoptions/#setWidth-int-) methods to specify the output image size in pixels. {{< tabs "render-pst-to-jpeg">}} {{< tab "JavaScript" >}} ```js import { Viewer, JpgViewOptions } from '@groupdocs/groupdocs.viewer'; const viewer = new Viewer("sample.pst") // Convert the PST file to JPG. // {0} is replaced with the page numbers in the output image names. const viewOptions = JpgViewOptions("render-pst-to-jpeg/pst-to-jpg-page_{0}.jpg") // Set width and height. viewOptions.setWidth(950) viewOptions.setHeight(550) viewer.view(viewOptions) ``` {{< /tab >}} {{< tab "sample.pst" >}} {{< tab-text >}} `sample.pst` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/nodejs-java/_sample_files/rendering-basics/render-outlook-data-files/sample.pst) to download it. {{< /tab-text >}} {{< /tab >}} {{< /tabs >}} ## Get information about folders in an Outlook data file Follow the steps below to obtain information about folders contained in an Outlook data file. 1. Create a [ViewInfoOptions](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/viewinfooptions) instance for a specific view. 2. Call the [Viewer.getViewInfo](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer/viewer/#getViewInfo-com.groupdocs.viewer.options.ViewInfoOptions-) method, pass the `ViewInfoOptions` instance to this method as a parameter, and cast the returned object to the [OutlookViewInfo](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.results/outlookviewinfo/) type. 3. Use the [OutlookViewInfo.getFolders](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.results/outlookviewinfo/#getFolders--) method to obtain the list of folders in the Outlook data file. {{< tabs "get-pst-folders-info">}} {{< tab "JavaScript" >}} ```js import { Viewer, ViewInfoOptions } from '@groupdocs/groupdocs.viewer'; function readFolders(viewer, viewInfoOptions, folder) { viewInfoOptions.getOutlookOptions().setFolder(folder) const viewInfo = viewer.getViewInfo(viewInfoOptions) const folders = viewInfo.getFolders() for (let i = 0; i < folders.size(); i++) { console.log(" - ", folders.get(i).toString()) readFolders(viewer, viewInfoOptions, folders.get(i).toString()) } } const viewer = new Viewer("sample.pst") const viewInfoOptions = ViewInfoOptions.forHtmlView() const viewInfo = viewer.getViewInfo(viewInfoOptions) // Display information about the PST file. console.log("File type: " + viewInfo.getFileType()) console.log("Pages count: " + viewInfo.getPages().size()) // Display the list of folders that the PST file contains. console.log("The file contains the following folders:") console.log(" - /") readFolders(viewer, viewInfoOptions, "") ``` {{< /tab >}} {{< tab "sample.pst" >}} {{< tab-text >}} `sample.pst` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/nodejs-java/_sample_files/rendering-basics/render-outlook-data-files/sample.pst) to download it. {{< /tab-text >}} {{< /tab >}} {{< /tabs >}} ## Specify rendering options GroupDocs.Viewer supports the [OutlookOptions](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/outlookoptions) class that allows you to specify different options for rendering Outlook data files. To access these options, use the [setOutlookOptions](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/baseviewoptions/#setOutlookOptions-com.groupdocs.viewer.options.OutlookOptions-) method for one of the following classes (depending on the output file format): * [HtmlViewOptions](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/htmlviewoptions) * [PdfViewOptions](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/pdfviewoptions) * [PngViewOptions](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/pngviewoptions) * [JpgViewOptions](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/jpgviewoptions) ### Render a specific folder When you convert an OST or PST file to HTML, PDF, or image format, GroupDocs.Viewer renders messages from all folders contained in the file (including nested folders). If you want to render items from a specific folder, use the [OutlookOptions.setFolder](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/outlookoptions/#setFolder-java.lang.String-) method for a target view. Specify the folder name as follows: `{Parent folder name}\\{Subfolder name}`. {{< tabs "render-pst-specific-folder">}} {{< tab "JavaScript" >}} ```js import { Viewer, HtmlViewOptions } from '@groupdocs/groupdocs.viewer'; const viewer = new Viewer("sample.pst") // Create an HTML file. const viewOptions = HtmlViewOptions.forEmbeddedResources() // Render messages from the "Deleted Items" folder and its subfolders. viewOptions.getOutlookOptions().setFolder("Deleted Items") viewer.view(viewOptions) ``` {{< /tab >}} {{< tab "sample.pst" >}} {{< tab-text >}} `sample.pst` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/nodejs-java/_sample_files/rendering-basics/render-outlook-data-files/sample.pst) to download it. {{< /tab-text >}} {{< /tab >}} {{< /tabs >}} ### Limit the number of folder items to render When you load large Outlook data files, it may take a significant amount of time to retrieve and render file contents. To improve rendering performance, use the [OutlookOptions.setMaxItemsInFolder](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/outlookoptions/#setMaxItemsInFolder-int-) method to limit the number of rendered items (messages, contacts, or tasks) in each folder. The default property value is **50**. Set this property to **0** to render all existing items. The following example demonstrates how to specify the maximum number of folder items to render: {{< tabs "render-pst-limit-items">}} {{< tab "JavaScript" >}} ```js import { Viewer, HtmlViewOptions } from '@groupdocs/groupdocs.viewer'; const viewer = new Viewer("sample.pst") // Create an HTML file. const viewOptions = HtmlViewOptions.forEmbeddedResources() // Specify the maximum number of folder items. viewOptions.getOutlookOptions().setMaxItemsInFolder(30) viewer.view(viewOptions) ``` {{< /tab >}} {{< tab "sample.pst" >}} {{< tab-text >}} `sample.pst` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/nodejs-java/_sample_files/rendering-basics/render-outlook-data-files/sample.pst) to download it. {{< /tab-text >}} {{< /tab >}} {{< /tabs >}} ### Filter messages Microsoft Outlook allows you to filter messages by specific words in the message body or by part of the sender's or recipient's address. ![Filter messages in Microsoft Outlook](https://docs.groupdocs.com/viewer/nodejs-java/images/rendering-basics/render-outlook-files/filter-messages.png) With GroupDocs.Viewer, you can also filter messages before rendering an Outlook data file to HTML, PDF, or image format. To do this, use the following methods: * [OutlookOptions.setTextFilter](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/outlookoptions/#setTextFilter-java.lang.String-)---Allows you to render all messages that contain specific text in the subject or body. * [OutlookOptions.setAddressFilter](https://reference.groupdocs.com/viewer/nodejs-java/com.groupdocs.viewer.options/outlookoptions/#setAddressFilter-java.lang.String-)---Allows you to render all messages that contain specific text in the sender's or recipient's address. The following code sample filters messages in a PST file before rendering this file to HTML: {{< tabs "render-pst-filter-messages">}} {{< tab "JavaScript" >}} ```js import { Viewer, HtmlViewOptions } from '@groupdocs/groupdocs.viewer'; const viewer = new Viewer("sample.pst") // Create an HTML file. const viewOptions = HtmlViewOptions.forEmbeddedResources("render-pst-filter-messages/pst-to-html.html") // Set filters. viewOptions.getOutlookOptions().setTextFilter("Viewer") viewOptions.getOutlookOptions().setAddressFilter("groupdocs.com") viewer.view(viewOptions) ``` {{< /tab >}} {{< tab "sample.pst" >}} {{< tab-text >}} `sample.pst` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/nodejs-java/_sample_files/rendering-basics/render-outlook-data-files/sample.pst) to download it. {{< /tab-text >}} {{< /tab >}} {{< /tabs >}}