GroupDocs.Viewer for Java 3.2.0 Release Notes

Major Features

There are 36 improvements and fixes in this regular monthly release. The most notable are:

  • File detection from stream.
  • Introduced PdfFileOptions.
  • Introduced new conversion mechanism for multipage TIFF documents.
  • Introduced options to show/hide grid lines for excel documents.
  • Introduced jpeg image quality settings.
  • Introduced file description property which returns document type format.
  • Introduced method that returns supported document formats.
  • Introduced option that allows to set text document encoding.
  • Introduced Hide/Show the hidden sheets for Excel files option.
  • Custom localization engine to use custom locales from path.
  • Improved document processing fidelity and speed.
  • Improved quality of re-sized images.

Full List of Issues Covering all Changes in this Release

KeySummaryIssue Type
WEB-2128New conversion mechanism for displaying multipage TIFF filesNew Feature
VIEWERNET-542Implement option that allows to set text document encoding.New Feature
VIEWERNET-495Implement method that returns supported document formats.New Feature
VIEWERNET-494Implement file description property that returns document type format.New Feature
VIEWERNET-484Provide jpeg image quality setting.New Feature
VIEWERNET-469Implement configuration option that allows set cells sheet conversion mode when converting to pdf.New Feature
VIEWERNET-434Add support for Portuguese localeNew Feature
VIEWERNET-415Add ability to show/hide grid lines for excel filesNew Feature
VIEWERNET-393New conversion mechanism for displaying multipage TIFF filesNew Feature
VIEWERNET-389Implement PdfFileOptions same as another Options classes.New Feature
VIEWERNET-304Process files from stream without specifying fileName parameterNew Feature
VIEWERNET-525Implement storing cache files separately depends on use pdf option.Improvement
VIEWERNET-515Improve quality of re-sized images.Improvement
VIEWERNET-462Improve document processing fidelity and speedImprovement
VIEWERNET-436User provided Excel Spreadsheet does not follow MS Excel behavior when rendered to PDFImprovement
VIEWERNET-423Improve localization engine to use custom locales from pathImprovement
VIEWERNET-395Hide/Show the hidden sheets for Excel filesImprovement
WEB-2446DocuSign signed files not showing all contentBug
WEB-2445Doc to Pdf save errorBug
WEB-2441Empty htmlBug
WEB-2438Not all content of the pdf document rendered to htmlBug
WEB-2435High memory usage while converting to PdfBug
WEB-2402Specific eml file can’t be viewed in HTML modeBug
VIEWERNET-528Failed to rotate page if page number specified.Bug
VIEWERNET-514Resolution is set incorrectly when converting pdf to image.Bug
VIEWERNET-513Image re-sized incorrectly when re-sizing to larger dimensions.Bug
VIEWERNET-493Css classes are overridden in multiple pages documentsBug
VIEWERNET-486Shift_JIS encoded characters are not showing in proper formatBug
VIEWERNET-480PreloadPagesCount is not working in V3.0Bug
VIEWERNET-479Blurry document in Image Based renderingBug
VIEWERNET-472Invalid Parameter Exception on rendering PDF to HTMLBug
VIEWERNET-455Underline for some words/sentences when saving to html/imageBug
VIEWERNET-454Failed to convert .xlsx with fixed headers table to image.Bug
VIEWERNET-453Conversion of .xlsx with fixed headers table to pdf never completes.Bug
VIEWERNET-451Empty Value Exception on rendering PDF FileBug
VIEWERNET-438Invalid Parameter Exception on rendering Excel Spreadsheet to HTMLBug
VIEWERJAVA-1065Incorrect converting PPT file to HTMLBug
VIEWERJAVA-1120The .pdf document doesn’t renderedBug

Public API and Backward Incompatible Changes

How to show grid lines for Excel files

Show grid lines for Excel files in image representation

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath("C:\\storage");

// Create image handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = "document.xlsx";

// Set image options to show grid lines
ImageOptions options = new ImageOptions();
options.getCellsOptions().setShowGridLines(true);

List<PageImage> pages = imageHandler.getPages(guid, options);

for (PageImage page : pages)
{
    System.out.printf("Page number: " + page.getPageNumber());

    // Page image stream
    final InputStream imageContent = page.getStream();
}

Show grid lines for Excel files in html representation

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath("C:\\storage");

// Create html handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
String guid = "document.xlsx";

// Set html options to show grid lines
HtmlOptions options = new HtmlOptions();
options.getCellsOptions().setShowGridLines(true);
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());
}
How to deny showing multiple pages per sheet for Excel files

Multiple pages per sheet

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath("C:\\storage");

// Create image or html handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = "document.xlsx";

// Set pdf file one page per sheet option to false, default value of this option is true
PdfFileOptions pdfFileOptions = new PdfFileOptions();
pdfFileOptions.setGuid(guid);
pdfFileOptions.getCellsOptions().setOnePagePerSheet(false);

//Get pdf file
FileContainer fileContainer = imageHandler.getPdfFile(pdfFileOptions);

//The pdf file stream
final InputStream pdfStream = fileContainer.getStream();
How to get all supported formats

Get all supported document formats

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath("C:\\storage");

// Create image or html handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);

// Get supported document formats
DocumentFormatsContainer documentFormatsContainer = imageHandler.getSupportedDocumentFormats();
Map<String, String> supportedDocumentFormats = documentFormatsContainer.getSupportedDocumentFormats();

for (Map.Entry<String, String> supportedDocumentFormat : supportedDocumentFormats.entrySet()) {
    System.out.println(String.format("Extension: '%s'; Document format: '%s'", supportedDocumentFormat.getKey(), supportedDocumentFormat.getValue()));
}
Show hidden sheets for Excel files

Show hidden sheets for Excel files in image representation

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath("C:\\storage");

// Create image handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = "document.xlsx";

// Set image options to show grid lines
ImageOptions options = new ImageOptions();
options.getCellsOptions().setShowGridLines(true);

List<PageImage> pages = imageHandler.getPages(guid, options);

for (PageImage page : pages)
{
    System.out.printf("Page number: " + page.getPageNumber());

    // Page image stream
    final InputStream imageContent = page.getStream();
}

Show hidden sheets for Excel files in image representation

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.setStoragePath("C:\\storage");

// Create image or html handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = "document.xlsx";

// Set image options to show grid lines
ImageOptions options = new ImageOptions();
options.getCellsOptions().setShowHiddenSheets(true);

DocumentInfoContainer container = imageHandler.getDocumentInfo(new DocumentInfoOptions(guid));

for (PageData page : container.getPages())
 System.out.println(String.format("Page number: %d, Page Name: %s, IsVisible: %s", page.getNumber(), page.getName(), page.isVisible()));

List<PageImage> pages = imageHandler.getPages(guid, options);

for (PageImage page : pages) {
 System.out.println("Page number: " + page.getPageNumber());

 // Page image stream
 final InputStream imageContent = page.getStream();
}
Localization

How to create and use file with localized strings

1. Create xml file with localized strings

XML

<?xml version="1.0" encoding="utf-8" ?>
<root>
  <data name="EXC_TMPL_CORRUPTED_OR_DAMAGED_FILE">
    <value>Could not load file '{0}', file is corrupted or damaged.</value>
  </data>
  <data name="EXC_TMPL_FILE_TYPE_NOT_SUPPORTED">
    <value>File type '{0}' is not supported.</value>
  </data>
  <data name="EXC_TMPL_INVALID_PASSWORD">
    <value>Unable to decrypt file '{0}'. Password is invalid.</value>
  </data>
  <data name="EXC_TMPL_PASSWORD_PROTECTED_FILE">
    <value>Unable to open encrypted file '{0}'. Please provide password.</value>
  </data>
  <data name="EXC_TMPL_STORAGE_PATH_NOT_SPECIFIED">
    <value>The storage path is not specified. Please provide storage path.</value>
  </data>
  <data name="EXC_TMPL_CACHE_FILE_NOT_FOUND">
    <value>Could not find cached file '{0}'.</value>
  </data>
  <data name="EXC_TMPL_GUID_NOT_SPECIFIED">
    <value>The file GUID is not specified. Please provide file GUID.</value>
  </data>
  <data name="EXC_TMPL_TRANSFORMATION_FAILED_PAGE_NOT_EXIST">
    <value>Unable to transform file '{0}'. Page number '{1}' does not exist.</value>
  </data>
</root>

2. Save file to disc e.g. “c://locales” with following name “LocalizedStrings-{Language Culture Name}.xml” where {Language Culture Name} is your culture name e.g. “fr-FR”. So path is “c://locales//LocalizedStrings-fr-FR.xml”

3. Setup ViewerConfig to use file with localized strings created above

// Setup GroupDocs.Viewer config
ViewerConfig viewerConfig = new ViewerConfig();
viewerConfig.setStoragePath("c:\\storage");
viewerConfig.setLocalesPath("c:\\locales");

// Create html handler
ViewerHandler.CultureInfo cultureInfo = new ViewerHandler.CultureInfo("fr-FR");
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(viewerConfig, cultureInfo);
How to set Words, Cells and Email document encoding

How to set Words, Cells and Email document encoding

//Initialize viewer config
ViewerConfig viewerConfig = new ViewerConfig();
viewerConfig.setStoragePath("c:\\storage");

//Initialize viewer handler
ViewerImageHandler viewerImageHandler = new ViewerImageHandler(viewerConfig);

//Set encoding
Charset encoding = Charset.forName("shift-jis");

//Set image options
ImageOptions imageOptions = new ImageOptions();
imageOptions.getWordsOptions().setEncoding(encoding);
imageOptions.getCellsOptions().setEncoding(encoding);
imageOptions.getEmailOptions().setEncoding(encoding);

//Get words document pages with encoding
String wordsDocumentGuid = "document.txt";
List<PageImage> wordsDocumentPages = viewerImageHandler.getPages(wordsDocumentGuid, imageOptions);

//Get cells document pages with encoding
String cellsDocumentGuid = "document.csv";
List<PageImage> cellsDocumentPages = viewerImageHandler.getPages(cellsDocumentGuid, imageOptions);

//Get email document pages with encoding
String emailDocumentGuid = "document.msg";
List<PageImage> emailDocumentPages = viewerImageHandler.getPages(emailDocumentGuid, imageOptions);

//Get words document info with encoding
DocumentInfoOptions wordsDocumentInfoOptions = new DocumentInfoOptions(wordsDocumentGuid);
wordsDocumentInfoOptions.getWordsDocumentInfoOptions().setEncoding(encoding);
DocumentInfoContainer wordsDocumentInfoContainer = viewerImageHandler.getDocumentInfo(wordsDocumentInfoOptions);

//Get cells document info with encoding
DocumentInfoOptions cellsDocumentInfoOptions = new DocumentInfoOptions(cellsDocumentGuid);
cellsDocumentInfoOptions.getCellsDocumentInfoOptions().setEncoding(encoding);
DocumentInfoContainer cellsDocumentInfoContainer = viewerImageHandler.getDocumentInfo(cellsDocumentInfoOptions);

//Get email document info with encoding
DocumentInfoOptions emailDocumentInfoOptions = new DocumentInfoOptions(emailDocumentGuid);
emailDocumentInfoOptions.getEmailDocumentInfoOptions().setEncoding(encoding);
DocumentInfoContainer emailDocumentInfoContainer = viewerImageHandler.getDocumentInfo(emailDocumentInfoOptions);