GroupDocs.Viewer for Java 17.5.0 Release Notes

Note
This page contains release notes for GroupDocs.Viewer for Java 17.5.0.

Major Features

This release includes new features, improvements, and fixes. The most notable are:

  • Added file formats support
    • Microsoft Visio: VSTX, VSSX
    • OneNote: ONE
    • DjVu (multi-layer raster image)
  • Added option to hide tracked changes when converting Text documents
  • Added option to delete annotations when rendering PDF documents
  • Added option for adjusting the size when rendering CAD documents
  • Added option for specifying Layouts when rendering CAD documents
  • Added option that switches on more accurate rendering of complex PDF documents

Full List of Issues Covering all Changes in this Release

KeySummaryCategory
WEB-2143Get print URl for document in JavaScript APINew Feature
VIEWERNET-739Add DJVU file format supportNew Feature
VIEWERNET-797Hide tracked changes when converting Words documentsNew Feature
VIEWERNET-1066Implement setting to delete annotations when rendering pdf documentsNew Feature
VIEWERNET-1100Integrate Dynabic.Metered into GroupDocs.ViewerNew Feature
VIEWERNET-1106Implement settings for adjusting the size of CAD documents renderingNew Feature
VIEWERNET-1109Add VSSX file format supportNew Feature
VIEWERNET-1110Add VSTX file format supportNew Feature
VIEWERNET-1146Implement setting for specifying Layouts when rendering Cad documentsNew Feature
VIEWERNET-474Render one or range of worksheets from large excel file.Improvement
VIEWERNET-1076Remove obsolete CountPagesToConvert and PageNumbersToConvert RenderOptions propertiesImprovement
VIEWERNET-1077Add code examples to PdfOptions class documentation commentsImprovement
VIEWERNET-1078Add code examples to CellsOptions class documentation commentsImprovement
VIEWERNET-1079Add code examples to DiagramOptions class documentation commentsImprovement
VIEWERNET-1080Add code examples to EmailOptions class documentation commentsImprovement
VIEWERNET-1084Remove members marked as obsolete in previous versionsImprovement
VIEWERNET-1161Implement a setting that switches on more accurate rendering of pdf documentsImprovement
VIEWERNET-1163Do not set resource prefix when HtmlResourcePrefix is empty stringImprovement
VIEWERNET-1164Improve look of comments in API reference documentationImprovement
VIEWERNET-1167CellsOptions.ShowGridLines property does not work when rendering Cells to PDFImprovement
VIEWERNET-1170Extend support for setting JpegQuality when rendering documents as pdfImprovement
VIEWERNET-1190Throw GroupDocsViewerException when file type can’t be determined for passed streamImprovement
VIEWERNET-1194Create lower-case name when rendering document from streamImprovement
VIEWERJAVA-1205CustomCacheHandler is written for S3 Bucket but still uses local disk for cacheImprovement
VIEWERJAVA-1363Pdf rendering to HTML taking a lot of timeImprovement
WEB-1152Color filling isn’t displayed for some objectsBug
VIEWERNET-756Incorrect Font Color in Rendering Excel to HtmlBug
VIEWERNET-793Email attachments are not found when setting UsePDF to trueBug
VIEWERNET-874HTMLSaveOptions.DefaultFont setting doesn’t work properlyBug
VIEWERNET-938Save method requires System.Web referenceBug
VIEWERNET-987Incomplete image when converting specific dwgBug
VIEWERNET-1025Character’s size issue when rendering PDF document into HTMLBug
VIEWERNET-1026API is rendering PDF document into blank HTML pagesBug
VIEWERNET-1038Incorrect resource relative path when rendering to HtmlBug
VIEWERNET-1091Black background when rendering pps or ppt to imageBug
VIEWERNET-1094Issue in HtmlResourcePrefix when Rendering .msg FileBug
VIEWERNET-1095Issue with Underline Text when Rendering PDF into HTMLBug
VIEWERNET-1099IgnoreResourcePrefixForCss is ignored when rendering Words documentsBug
VIEWERNET-1133Overflow Text is Not Visible when Rendering Excel Sheet to HTMLBug
VIEWERJAVA-647PDF to HTML fixed layout issueBug
VIEWERJAVA-817Lines are too thin when rendering PDF as HTMLBug
VIEWERJAVA-818Pdf to Html space and positioning issuesBug
VIEWERJAVA-990PDF to HTML images color issueBug
VIEWERJAVA-1312getLastModificationDate is not showing last modification date as expectedBug
VIEWERJAVA-1314GroupDocs.Viewer for Java latest Jar file lacks few importsBug
VIEWERJAVA-1370Excel file with blank sheets not rendering to imageBug
VIEWERJAVA-1391Excel files are not rendering to imageBug
VIEWERJAVA-1392ImageOptions is not working as expectedBug
VIEWERJAVA-1490PPTX/XLSX documents are not rendering to Images properlyBug
VIEWERJAVA-1498Duplicate pages are generated in cache if API is used in trial modeBug
VIEWERJAVA-1513Image-based rendering issuesBug
VIEWERJAVA-1503Style-sheet link is incorrect if HTML is generated with ResourcesEmbedded = falseBug

 Public API and Backward Incompatible Changes

Note
This section lists public API changes that were introduced in GroupDocs.Viewer for Java 17.5.0. It includes not only new and obsoleted public methods, but also a description of any changes in the behavior behind the scenes in GroupDocs.Viewer which may affect existing code. Any behavior introduced that could be seen as a regression and modifies existing behavior is especially important and is documented here.

File format support

Support of following file formats has been added to GroupDocs.Viewer.

  • DJVU 
  • VSSX 
  • VSTX  
  • ONE

Using Dynabic.Metered into GroupDocs.Viewer

You can also set Metered license as an alternative to license file. It is a new licensing mechanism that will be used along with existing licensing method. It is useful if you want to be billed based on the usage of the API features. For more details, please refer to Metered Licensing FAQ section.

// Set metered key
Metered metered = new Metered();
metered.setMeteredKey("****", "****");

Adjusting the size while rendering CAD documents

When CAD documents are rendered, the size of the render result is adjusted by API automatically depending on the size of the initial document. You may adjust the size of resulting document by setting CadOptions property as shown in the example.

Setting result image size when rendering Cad documents

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath(STORAGE_PATH);
 
// Create image handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = "document.dwg";
 
// Set Cad options to render content with a specified size
ImageOptions options = new ImageOptions();
options.getCadOptions().setHeight(750);
options.getCadOptions().setWidth(450);
 
// Get pages
List<PageImage> pages = imageHandler.getPages(guid, options);
 
for (PageImage page : pages)
{
    System.out.println("Page number: " + page.getPageNumber());
    InputStream imageContent = page.getStream();
}

The following logic for sizing CAD document rendering is applied:

  1. If both CadOptions.Height and CadOptions.Width properties are set, the resulting image will have the same size in pixels
  2. If only one of CadOptions.Height and CadOptions.Width is set, the value of another side will be calculated from the ratio in the original document. If  CadOptions.Height is set as 600 and the ratio of the height to width in original CAD document is 6 to 5, then the width of the resulting image will be 500 px
  3. If not one of CadOptions.Height and CadOptions.Width is set or set as 0, the CadOptions.ScaleFactor will be used to form resulting image size. The data type of this property is float, values higher than 1 will enlarge resulting image and values between 0 and 1 will make the image smaller. If the render result image size is equal to 200 px to 200 px, when CadOptions.ScaleFactor is equal to 1, then setting this value to 0.1 will provide image with 20 px to 20 px dimension
  4. When CadOptions are not set size of resulting image is set  by API

The same logic is applied when rendering to HTML. When rendering to PDF, generally only height to width ratio matters

Rendering pdf documents without annotations

When rendering PDF documents with annotations, by default annotations are represented in the resultant document. But sometimes you might want not to include annotations in resultant documents. In such cases set RenderOptions (ImageOptions or HtmlOptions)  PdfOptions.DeleteAnnotations property as true and pass it to GetPages method of corresponding ViewerHandler (ViewerImageHandler or ViewerHtmlHandler) as shown in the example below.

How to render pdf documents and exclude annotations from rendering result

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath(STORAGE_PATH);
 
// Create html handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
String guid = "DocumentWithAnnotations.pdf";
 
// Set pdf options to render content without annotations
HtmlOptions options = new HtmlOptions();
options.getPdfOptions().setDeleteAnnotations(true); // Default value is false
 
// Get pages
List<PageHtml> pages = htmlHandler.getPages(guid, options);
 
for (PageHtml page : pages) {
    System.out.println("Page number: " + page.getPageNumber());
    System.out.println("Html content: " + page.getHtmlContent());
}

In order to get original file without annotations, set PdfFileOptions PdfOptions.DeleteAnnotations property as true and pass it to GetPdfFile method of corresponding ViewerHandler (ViewerImageHandler or ViewerHtmlHandler) as shown in the example below.

How to get original pdf document without annotations

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath(STORAGE_PATH);
 
// Create image handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = "DocumentWithAnnotations.pdf";
 
// Set pdf options to get original file without annotations
PdfFileOptions pdfFileOptions = new PdfFileOptions();
pdfFileOptions.getPdfOptions().setDeleteAnnotations(true); // Default value is false
 
// Get original pdf document without annotations
FileContainer fileContainer = imageHandler.getPdfFile(guid, pdfFileOptions);
// Access result pdf document using fileContainer.Stream property

Rendering Words documents with tracked changes

Rendering Words document, by default will provide result without tracked changes. If you want to see tracked changes in your render result use WordsOptions.setShowTrackedChanges property of RenderOptions (ImageOptions or HtmlOptions) and pass it to corresponding ViewerHandler (ViewerImageHandler or ViewerHtmlHandler) as shown in sample code below.

Rendering words documents with tracked changes

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath(STORAGE_PATH);
 
// Create html handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
String guid = "document.docx";
 
// Set pdf options to render tracked changes 
HtmlOptions options = new HtmlOptions();
options.getWordsOptions().setShowTrackedChanges(true); // Default value is false
 
// Get pages 
List<PageHtml> pages = htmlHandler.getPages(guid, options);
 
for (PageHtml page : pages) {
    System.out.println("Page number: " + page.getPageNumber());
    System.out.println("Html content: " + page.getHtmlContent());
}

To get PDF representation of tracked changes from Words document, set PdfFileOptions WordsOptions.setShowTrackedChanges property as true and pass it to GetPdfFile method of the corresponding ViewerHandler (ViewerImageHandler or ViewerHtmlHandler) as shown in the example below.

Get PDF representation of Words document with tracked changes

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath(STORAGE_PATH);
 
// Create image handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = "DocumentWithAnnotations.pdf";
 
// Set pdf options to get pdf file with tracked changes
PdfFileOptions pdfFileOptions = new PdfFileOptions();
pdfFileOptions.getWordsOptions().setShowTrackedChanges(true); // Default value is false
 
// Get pdf document with tracked changes
FileContainer fileContainer = imageHandler.getPdfFile(guid, pdfFileOptions);
// Access result pdf document using fileContainer.Stream property

How to set output quality when rendering documents into PDF

When documents are rendered as PDF, sometimes we might be unhappy with a very big size of the resulting pdf, or we might intentionally want to reduce the quality of render result. For this purpose, you can use pdfFileOptions.setJpegQuality property as shown in the example below. Valid values for this option are in the range between 1 and 100, where 100 stands for the best quality and biggest size and 1 stands for the lowest quality and lowest size of resulting pdf document. The default value is 90. Since the version 17.5.0 support for additional document types has been added. Please refer to the table below to see which document types are affected.

How to adjust the quality and size when rendering DjVu into pdf

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath(STORAGE_PATH);
 
// Create html handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = "document.djvu";
 
// Set pdf options JpegQuality in a range between 1 and 100
PdfFileOptions pdfFileOptions = new PdfFileOptions();
pdfFileOptions.setJpegQuality(5);
 
// Get file as pdf
FileContainer container = imageHandler.getPdfFile(guid, pdfFileOptions);
 
System.out.println("Name: " + container.getStream().available());
List of formats affected by PdfFileOptions.JpegQuality property when rendered as pdf
Format NameDescription
Microsoft WordAffects JPEG images contained in Microsoft Word documents
Microsoft PowerPointAffects JPEG images contained in Microsoft PowerPoint documents
Microsoft OutlookAffects JPEG images set as a background in email documents msg and eml formats
OpenDocument FormatsAffects JPEG images contained in OpenDocument presentation (odp) andOpenDocument text (odt) formats
Image filesAffects rendering from PSD, TIFF, multi-page TIFF, WebP, SVG and DjVu formats
MetafileAffects rendering from WMF and EMF formats
Microsoft VisioAffects JPEG images contained inside Microsoft Visio documents

Rendering layouts from CAD documents

How to render Model together with Layouts from CAD documents

When CAD documents are rendered, by default we get only Model representation. In order to render Model and all non-empty Layouts within CAD document, in version 17.5.0 a new property cadOptions.setRenderLayouts of an ImageOptions and HtmlOptions has been introduced.

Rendering Model and all non empty Layouts from CAD document

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath(STORAGE_PATH);
 
// Create html handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = "document.dwg";
 
// Set CAD options to render Model and all non empty Layouts
ImageOptions options = new ImageOptions();
options.getCadOptions().setRenderLayouts(true);
 
// Get pages
List<PageImage> pages = imageHandler.getPages(guid, options);
 
for (PageImage page : pages)
{
    System.out.println("Page number: " + page.getPageNumber());
    InputStream imageContent = page.getStream();
}

How to render specific Layout from CAD documents

Since the version 17.5.0, in order to render specific Layout, please use cadOptions.setLayoutName property of an ImageOptions and HtmlOptions. When this property is set, cadOptions.setRenderLayouts property will be ignored.

Rendering specific Layout from Cad document

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath(STORAGE_PATH);
 
// Create html handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = "document.dwg";
 
// Set CAD options to render specific Layout
ImageOptions options = new ImageOptions();
options.getCadOptions().setLayoutName("MyFirstLayout");
 
// Get pages
List<PageImage> pages = imageHandler.getPages(guid, options);
 
for (PageImage page : pages)
{
    System.out.println("Page number: " + page.getPageNumber());
    InputStream imageContent = page.getStream();
}

How to obtain the list of Layouts contained in CAD document

To get the list of Layouts contained in CAD document, use getDocumentInfo of corresponding ViewerHandler as shown in the example:

How to get the list of Layouts from CAD document

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath(STORAGE_PATH);
 
// Create html handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = "document.dwg";
 
// Set CAD options to get the full list of Layouts
DocumentInfoOptions documentInfoOptions = new DocumentInfoOptions();
documentInfoOptions.getCadOptions().setRenderLayouts(true);
 
// Get DocumentInfoContainer and iterate through pages
DocumentInfoContainer documentInfoContainer = imageHandler.getDocumentInfo(guid, documentInfoOptions);
 
System.out.println("Name: " + documentInfoContainer.getName());
System.out.println("Name: " + documentInfoContainer.getPages());

Managing text overflow when rendering Cells documents to HTML

When cells documents are rendered into HTML, overflowed text inside the cell overlays subsequent cells until it meets nonempty cell. Since the version 17.5.0, there is a setting to configure the mode which will be used for rendering overflowed text:

  1. To set the overflowed text to be hidden, set CellsOptions.TextOverflowMode of HtmlOption to TextOverflowMode.HideText as shown in the example below.
  2. To set the overflowed text to overlay subsequent cells untill it meets non empty cell, set CellsOptions.TextOverflowMode of HtmlOption to TextOverflowMode.OverlayIfNextIsEmpty. This is a default value of the CellsOptions.TextOverflowMode.
  3. To set the overflowed text to overlay subsequent cells even they are not empty, set CellsOptions.TextOverflowMode of HtmlOption to TextOverflowMode.Overlay.

Setting overflowed text to be hidden when rendering Cells documents

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath(STORAGE_PATH);
 
// Create html handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
String guid = "document.xlsx";
 
// Set Cells options to hide overflowing text
HtmlOptions options = new HtmlOptions();
options.getCellsOptions().setTextOverflowMode(TextOverflowMode.HideText);
 
// Get pages
List<PageHtml> pages = htmlHandler.getPages(guid, options);
 
for (PageHtml page : pages) {
    System.out.println("Page number: " + page.getPageNumber());
    final String htmlContent = page.getHtmlContent();
    System.out.println("Html content: " + htmlContent);
}

Enabling precise mode when rendering pdf documents

Note
Since the version 17.5.0 PreventGlyphsGrouping property of PdfOptions class is set deprecated, use this feature instead.

When pdf documents are rendered, we get similar representation in image and HTML formats, but sometimes result of rendering may contain shifted characters, symbols or document objects.To improve render result in such cases please use pdfOptions.setEnablePreciseRendering as shown in the example below. This option includes technics for more accurate representation of documents both in HTML and image formats.

How to render pdf document in a precise mode.

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath(STORAGE_PATH);
 
// Create html handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
String guid = "document.pdf";
 
// Set pdf options to render content in a precise mode
HtmlOptions options = new HtmlOptions();
options.getPdfOptions().setEnablePreciseRendering(true); // Default value is false
 
// Get pages
List<PageHtml> pages = htmlHandler.getPages(guid, options);
 
for (PageHtml page : pages) {
    System.out.println("Page number: " + page.getPageNumber());
    System.out.println("Html content: " + page.getHtmlContent());
}

Rendering documents with comments

Some document types like Microsoft Word, Excel, OpenOffice Text and Spreadsheet may contain comments. By default comments are not rendered. Since the version 17.5.0 there is a new option - setRenderComments property of RenderOptions (ImageOptions or HtmlOptions) that enables comments rendering. Currently, this option works for Microsoft Word, Excel, OpenOffice Text and Spreadsheet document types. We are planning to extend support for this option to work with other document types in nearest coming API versions. See example below on how to use this option.

Rendering Microsoft Word document with comments

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath(STORAGE_PATH);
 
// Create html handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
String guid = "document.docx";
 
// Set words options to render content with comments
HtmlOptions options = new HtmlOptions();
options.setRenderComments(true); // Default value is false
 
 
// Get pages
List<PageHtml> pages = htmlHandler.getPages(guid, options);
 
for (PageHtml page : pages) {
    System.out.println("Page number: " + page.getPageNumber());
    final String htmlContent = page.getHtmlContent();
    System.out.println("Html content: " + htmlContent);
}

To get PDF representation with comments, set pdfFileOptions.setRenderComments property as true and pass it to getPdfFile method of the corresponding ViewerHandler (ViewerImageHandler or ViewerHtmlHandler) as shown in example below.

Get PDF representation of Microsoft Word document with comments

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath(STORAGE_PATH);
 
// Create html handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = "document.docx";
 
// Set pdf options to get pdf file with comments
PdfFileOptions pdfFileOptions = new PdfFileOptions();
pdfFileOptions.setRenderComments(true); // Default value is false
 
// Get pdf document with comments
FileContainer container = imageHandler.getPdfFile(guid, pdfFileOptions);
 
System.out.println("Name: " + container.getStream().available());
assertTrue(container.getStream().available() > 0);

Rendering document from stream 

  1. Throw GroupDocsViewerException when file type can’t be determined for passed stream - GroupDocs.Viewer will throw GroupDocsViewerException instead of EndOfStreamException when GroupDocs.Viewer can’t determine file type
  2. Create lower-case name when rendering document from the stream - GroupDocs.Viewer will create a lower-case name for the document. Name consists of 32 digits separated by hyphens: 00000000-0000-0000-0000-000000000000 (GUID) and extension e.g. 00000000-0000-0000-0000-000000000000.docx