View File

There are four overloads to the ViewFile method which are mentioned below. Returns a valid token if successful. If the return value is blank, it indicates that there was some error viewing the file. Please check the InternalException property.

string filePath, BaseOptions config
var pdfOptions = new PdfOptions{ AllowSearch = true };
ViewFile("C:\files\Word.doc", new WordOptions {ConvertPdf = true, PdfOptions = pdfOptions});
Uri docUrl, BaseOptions config
ViewFile("https://site.com/Sample.pptx", new PptOptions());
byte[] fileBytes, ViewFileFormat fileExt, BaseOptions config
var xlsBytes = File.ReadAllBytes("C:\files\Excel.xls");
ViewFile(xlsBytes, ViewFileFormat.Xls, new ExcelOptions{ExportOnePagePerWorkSheet = true});
Stream fileStream, FileInfo fileInfo, BaseOptions config
var filePath = "C:\files\Resume.pdf";
using var pdfStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
ViewFile(pdfStream, new FileInfo(filePath), new PdfOptions());