Document Viewer API

We are pleased to announce the release of version 18.6 of GroupDocs.Viewer for .NET. The latest version provides the support of rendering DXF format as well as the tiled rendering of the CAD documents. Furthermore, we have added the feature of forced password validation for password protected documents. Along with the new features, there are 14 improvements and bug fixes in this monthly release. Below is the list of new features, improvements, and fixes added in GroupDocs.Viewer for .NET 18.6.

Supported File Formats

GroupDocs.Viewer for .NET 18.6 supports rendering of DXF file format. For a complete list of supported file formats, please visit this documentation article.

Forced Password Validation

When password protected documents are rendered with the caching enabled, document password is validated only on the first call. All subsequent renderings provide output without checking the document password. In order to alter this behavior and let the API validate document password on each rendering, set ForcePasswordValidation property of the ViewerConfig as shown in the code snippet below.

//Init viewer config
ViewerConfig viewerConfig = new ViewerConfig();
viewerConfig.StoragePath = "c:\\storage";
  
//Set the password to be validated on every call
viewerConfig.ForcePasswordValidation = true;
// Init viewer html handler
ViewerHtmlHandler viewerHtmlHandler = new ViewerHtmlHandler(viewerConfig);
   
// Set the guid of the document you want to render
string guid = "with-images.pdf";
   
//Set document password
HtmlOptions htmlOptions = new HtmlOptions();
htmlOptions.Password = "documentpassword";
  
//Render document with specified options
List pages = viewerHtmlHandler.GetPages(guid, htmlOptions);

For more details on this feature, please visit this documentation article.

Tiled Rendering or Rendering by Coordinates of CAD Documents

Tiled rendering (or rendering by coordinates) is the process of rendering CAD documents (into an image, HTML or PDF) by dividing into square parts and rendering each part (or tile) separately. In tiled rendering, the amount of memory involved is reduced as compared to rendering the entire document at once. Since the version 18.6, tiled rendering is available for rendering DWG file format into image and HTML. When the tiled rendering is enabled, only the Model is rendered, and every tile composes a separate page. You can add as many tiles as you need. The following code snippet demonstrates how to render DWG drawing into an image by dividing into four equal parts.

 // Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
config.StoragePath = @"C:\storage";
   
// Create image handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
string guid = "document.dwg";
   
// Get document width and height
DocumentInfoContainer docInfo = imageHandler.GetDocumentInfo(guid);
int width = docInfo.Pages[0].Width;
int height = docInfo.Pages[0].Height;
  
// Set tile width and height as a half of image total width
int tileWidth = width / 2;
int tileHeight = height / 2;
  
int pointX = 0;
int pointY = 0;
//Create image options and add four tiles, one for each quarter
ImageOptions options = new ImageOptions();
Tile tile = new Tile(pointX, pointY, tileWidth, tileHeight);
options.CadOptions.Tiles.Add(tile);
pointX += tileWidth;
tile = new Tile(pointX, pointY, tileWidth, tileHeight);
options.CadOptions.Tiles.Add(tile);
  
pointX = 0;
pointY += tileHeight;
tile = new Tile(pointX, pointY, tileWidth, tileHeight);
options.CadOptions.Tiles.Add(tile);
  
pointX += tileWidth;
tile = new Tile(pointX, pointY, tileWidth, tileHeight);
options.CadOptions.Tiles.Add(tile);
// The pages list will contain four images, one for each quarter
List pages = imageHandler.GetPages(guid, options);
   
foreach (PageImage page in pages)
{
     Console.WriteLine("Page number: {0}", page.PageNumber); 
     Stream imageContent = page.Stream;
}

For more details on this feature, please visit this documentation article.

Bug Fixes

Following issues are fixed in version 18.6 of GroupDocs.Viewer for .NET.

  • Access to the path ‘c:\windows\system32\inetsrv\vs.bin’ is denied
  • Can’t set different default fonts when rendering PDF document
  • Incorrect rendering of items with background color in Visio document
  • GetFileList throws “Guid for file should contain extension” when file has no extension
  • Some STL files are not supported
  • Text color is incorrect when rendering PDF
  • The content of the cell is hidden when rendering Excel to HTML
  • Unable to render Presentation documents, after ViewerConfig.FontDirectories are added
  • Wrong number of layouts in DXF

Improvements

Following are the improvements that we have made in version 18.6.

  • Extended support for DefaultFontName setting to PDF documents when rendering into PDF
  • Added new property EmbedResources which will replace IsResourcesEmbedded property in HtmlOptions class
  • Support of empty string for ViewerConfig.CacheFolderName property
  • Eliminated the gap between the list of tasks and footer when rendering MS Project documents
  • Extended support for DefaultFontName option for CAD documents

We have a few channels and resources for you to download, learn, try and get technical support on our document viewer API.

Feedback

As always, if you have any questions or suggestions, feel free to write on our forum.