GroupDocs.Viewer for .NET 18.5 Release Notes

Major Features

There are 14 features, improvements, and fixes in this regular monthly release. The most notable are:

  • Changing language for Email document headers
  • Setting page size when rendering Email documents
  • Support for rendering password protected ODT and OTT formats

Full List of Issues Covering all Changes in this Release

KeySummaryCategory
VIEWERNET-1591Setting page size when rendering Email documents as PDF and imageNew Feature
VIEWERNET-1571Changing language for header of emailsNew Feature
VIEWERNET-1587Add new property EnableCaching which will replace UseCache property in ViewerConfig classImprovement
VIEWERNET-1580Add support for rendering password protected ODT and OTT formatsImprovement
VIEWERNET-1573Support JpegQuality option when rendering OneNote documents into PDFImprovement
VIEWERNET-1561Extend support for DefaultFontName option for MS Project documents when rendering into PDFImprovement
VIEWERNET-1595The voluminous email is not fully rendered into imageBug
VIEWERNET-1559Images and diagrams are missing when rendering OTS fileBug
VIEWERNET-1532Text’s shadow appears in the output HTMLBug
VIEWERNET-1527Issues when rendering Excel document with vertical Japanese writingBug
VIEWERNET-1464Text overlaps when viewing HTML in Mozilla FirefoxBug
VIEWERNET-1256Content is missing when rendering PDF document into HTMLBug
VIEWERNET-1016Link with external URL in PDF document is not rendered as hyperlinkBug
VIEWERNET-1599The output image is cropped when rendering HTML as imageBug

Public API and Backward Incompatible Changes

Setting page size when rendering Email documents as PDF and image

Since the version 18.5, it is possible to set output page size for rendering Email documents into PDF and images. To enable this feature, set the PageSize property of the EmailOptions class. Please note that for rendering into HTML the whole email message is rendered into one responsive HTML page and this new option will not influence the rendering. 

Rendering as Image (C#)

string guid = "long-email.msg";
  
//Instantiate Viewer Hanlder 
ViewerImageHandler imageHandler = new ViewerImageHandler();
  
//Set page size  
ImageOptions imageOptions = new ImageOptions();
imageOptions.EmailOptions.PageSize = PageSize.A4;
 
//Render document with custom page size
List<PageImage> pages = imageHandler.GetPages(guid, imageOptions);
 
//Use Stream property of the PageImage class, to get output image.
foreach (PageImage page in pages)
{
    Console.WriteLine(page.Stream.Length);
}

Rendering as PDF (C#)

string guid = "long-email.msg";
  
//Instantiate Viewer Hanlder 
ViewerImageHandler imageHandler = new ViewerImageHandler();
  
//Set page size  
PdfFileOptions pdfOptions = new PdfFileOptions();            
pdfOptions.EmailOptions.PageSize = PageSize.A4;
 
//Render document with custom page size
FileContainer pdfContainer = imageHandler.GetPdfFile(guid, pdfOptions);
 
//Use Stream property of the FileContainer class, to get the output PDF document.
Console.WriteLine(pdfContainer.Stream.Length);

Changing language for the header of emails

When rendering email messages, by default the API uses the English language to render field labels such as (From, To, Subject etc.). To change field labels, the API provides a new property called FieldLabels in EmailOptions class.

How to change field labels (C#)

 string guid = "email.msg";
  
//Instantiate Viewer Hanlder 
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler();
  
//Set field labels 
HtmlOptions htmlOptions = new HtmlOptions();
htmlOptions.EmailOptions.FieldLabels[EmailField.From] = "Sender";
htmlOptions.EmailOptions.FieldLabels[EmailField.To] = "Receiver";
htmlOptions.EmailOptions.FieldLabels[EmailField.Sent] = "Date";
htmlOptions.EmailOptions.FieldLabels[EmailField.Subject] = "Topic";
 
//Render document with custom field labels
List<PageHtml> pages = htmlHandler.GetPages(guid, htmlOptions);

List of Changes in v18.5

GroupDocs.Viewer.Config.ViewerConfig

Public bool UseCache property is set obsolete

This property will be removed in version 18.8, please use EnableCaching property instead.

Public bool EnableCaching property added

Use this property to enable caching as a replacement for UseCache property.

Enabling cache (C#)

string guid = "document.docx";
 
// Setup GroupDocs.Viewer config with cache enabled
ViewerConfig config = new ViewerConfig();
config.EnableCaching = true; 
 
// Pass configurations to ViewerHandler and get output pages
ViewerImageHandler handler = new ViewerImageHandler(config); 
List<PageImage> pages = handler.GetPages(guid);
Public string DefaultFontName property has been removed

Please use DefaultFontName property of the ImageOptions, HtmlOptions, DocumentInfoOptions or PdfFileOptions class instead as show in example below.

// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.StoragePath = @"C:\storage";
 
string guid = "document.docx";
ViewerImageHandler handler = new ViewerImageHandler(config);
 
//Initialize a new instance of an ImageOptions class and set its DefaultFontName property 
ImageOptions options = new ImageOptions();
options.DefaultFontName = "Calibri";
 
List<PageImage> pages = handler.GetPages(guid, options);

GroupDocs.Viewer.Converter.Options.EmailField

public static class EmailField added

This class contains supported Email document fields.

GroupDocs.Viewer.Converter.Options.EmailOptions

public Dictionary<string, string> FieldLabels property added

Use this property to specify custom labels for Email document fields.

Set labels (C#)

string guid = "email.msg";
 
//Instantiate Viewer Hanlder 
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler();
 
//Set field labels 
HtmlOptions htmlOptions = new HtmlOptions();
htmlOptions.EmailOptions.FieldLabels[EmailField.From] = "Sender";
htmlOptions.EmailOptions.FieldLabels[EmailField.To] = "Receiver";
htmlOptions.EmailOptions.FieldLabels[EmailField.Sent] = "Date";
htmlOptions.EmailOptions.FieldLabels[EmailField.Subject] = "Topic";
 
//Render document with custom field labels
List<PageHtml> pages = htmlHandler.GetPages(guid, htmlOptions);
public PageSize property added

Use this option to set the output page size for rendering into images and PDF.

Render as image (C#)

string guid = "long-email.msg";
  
//Instantiate Viewer Hanlder 
ViewerImageHandler imageHandler = new ViewerImageHandler();
  
//Set page size  
ImageOptions imageOptions = new ImageOptions();
imageOptions.EmailOptions.PageSize = PageSize.A4;
 
//Render document with custom page size
List<PageImage> pages = imageHandler.GetPages(guid, imageOptions);
 
//Use Stream property of the PageImage class, to get output image.
foreach (PageImage page in pages)
{
    Console.WriteLine(page.Stream.Length);
}

Render as PDF (C#)

string guid = "long-email.msg";
  
//Instantiate Viewer Hanlder 
ViewerImageHandler imageHandler = new ViewerImageHandler();
  
//Set page size  
PdfFileOptions pdfOptions = new PdfFileOptions();            
pdfOptions.EmailOptions.PageSize = PageSize.A4;
 
//Render document with custom page size
FileContainer pdfContainer = imageHandler.GetPdfFile(guid, pdfOptions);
 
//Use Stream property of the FileContainer class, to get the output PDF document.
Console.WriteLine(pdfContainer.Stream.Length);