Rendering Unsupported File Formats in Vizit

With Vizit 6.0 comes the ability to write and register custom format converters for Vizit. This article walks you through the process of developing and registering a custom format converter.

Getting Started

If you haven't already, take a look at this article and follow the instructions in it to get started writing your custom code:

The rest of this article will explain the details of how to write the specific code for rendering unsupported file formats in Vizit.

The Basics

Vizit 6.0 contains a new assembly named Vizit.API.Interfaces. For custom converters, you must implement the IPdfConverter interface which contains two methods and a property.

bool CanConvertToPdf(string extension);

void ConvertToPdf(Stream source, Stream destination);

string Id { get; }

Implementing the IPdfConverter Interface

When a document is first loaded in Vizit, it must be in a format that Vizit supports natively. For Word, Excel, PowerPoint and a number of others, Vizit converts these documents into PDF format for more efficient viewing. Subsequently, the PDF frames are converted to PNG for easy display in a web browser without additional plugins. With the addition of the IPdfConverter interface, Vizit now queries every registered IPdfConverter against the target file's extension. The first to respond will be tasked with converting the file to a PDF.

This example required Aspose.Imaging. It can be run without a license, but watermarks will be displayed on the frames.

The following is an example CanConvertToPdf implementation which returns true if the incoming extension is ".dxf".

public bool CanConvertToPdf(string extension)
return extension == ".dxf";

Next, we have an example implementation of ConvertToPdf:

public void ConvertToPdf(Stream source, Stream destination)
using (Image img = Image.Load(source))
PdfOptions options = new PdfOptions
PageWidth = 800,
PageHeight = 600,
ScaleMethod = Aspose.Imaging.FileFormats.Cad.ScaleType.GrowToFit
img.Save(destination, options);

As with every Vizit plugin, you must implement the getter of the Id property. The value of this may not change. It is the unique value identifying this plugin.

public string Id { get { return "Contoso.CompanyLogoWatermark"; } }

Cache During Development

To avoid converting documents every time they are displayed, Vizit caches the resulting PDF. During development, this can be problematic. Follow the instructions outlined in this KB to disable Vizit's cache during development:

In-Document Search

If your converter generates a searchable PDF, you will be able to use the In-Document Search capabilities in Vizit Essential to search through the document.

Have more questions? Submit a request


Article is closed for comments.
Powered by Zendesk