public StringBuilder BuildControl(string filePhysicalPath, string fileVirtualPath, string tempDirectoryPhysicalPath, string tempDirectoryVirtualPath, string appDomain, string appRootUrl) { try { string fileExtension = Path.GetExtension(fileVirtualPath); string frameSource = fileVirtualPath; SupportedExtensions extension = (SupportedExtensions)Enum.Parse(typeof(SupportedExtensions), fileExtension.Replace(".", "")); IConverter converter = ConverterFactory.GetConverter(extension); if (converter != null) { string tempFileName = converter.Convert(filePhysicalPath, tempDirectoryPhysicalPath); if (string.IsNullOrEmpty(tempFileName)) { throw new Exception("An error ocurred while trying to convert the file"); } frameSource = string.Format("{0}/{1}", tempDirectoryVirtualPath, tempFileName); } if (PdfRenderer == PdfRenderers.PdfJs && Enum.IsDefined(typeof(PdfJsSupportedExtensions), extension.ToString())) { frameSource = string.Format("{0}{1}Scripts/pdf.js/web/viewer.html?file={0}{2}", appDomain, appRootUrl, frameSource); } else { frameSource = string.Format("{0}/{1}", appDomain, frameSource); } StringBuilder sb = new StringBuilder(); sb.Append("<iframe "); if (!string.IsNullOrEmpty(ID)) { sb.Append("id=" + ClientID + " "); } sb.Append("src=" + frameSource + " "); sb.Append("width=" + Width.ToString() + " "); sb.Append("height=" + Height.ToString() + ">"); sb.Append("</iframe>"); return(sb); } catch { return(new StringBuilder("Cannot display document viewer")); } }