public ConversionEngineException(string message, string engineProcessOutput, string conversionType, ConversionEngine engine, Exception innerException) : base(message, innerException) { this.ConversionType = conversionType; this.EngineName = engine.GetType().Name; this.EngineProcessOutput = engineProcessOutput; }
public byte[] ConvertText(string text, ConversionOptions options) { using (ConversionEngine engine = m_engineFactory.ConstructTextEngine(text)) { engine.ConvertToPdf(options); return(engine.OutputFile); } }
public byte[] CombinePdfs(List <byte[]> sourcePdfs, ConversionOptions options) { if (sourcePdfs == null || sourcePdfs.Count == 0) { throw new MissingSourceException("No pdfs were specified."); } using (ConversionEngine engine = m_engineFactory.ConstructPdfEngine(sourcePdfs)) { engine.ConvertToPdf(options); return(engine.OutputFile); } }
public byte[] ConvertHtmlList(string[] html, HtmlConversionOptions options) { if (html == null || html.Length == 0) { throw new MissingSourceException("No html was specified."); } using (ConversionEngine engine = m_engineFactory.ConstructHtmlEngine(html)) { engine.ConvertToPdf(options); return(engine.OutputFile); } }
public byte[] ConvertUrls(string[] urls, HtmlConversionOptions options) { if (urls == null || urls.Length == 0) { throw new MissingSourceException("No Urls were specified."); } foreach (string url in urls) { if (!IsAbsoluteUrl(url)) { throw new UnsupportedSourceException("The specified url is not an absolute path.", url.ToString()); } } using (ConversionEngine engine = m_engineFactory.ConstructUrlEngine(urls)) { engine.ConvertToPdf(options); return(engine.OutputFile); } }
public byte[] ConvertFiles(Dictionary <string, byte[]> files, ConversionOptions options) { if (files == null || files.Count == 0) { throw new MissingSourceException("No files were specified."); } List <byte[]> converted = new List <byte[]>(); foreach (KeyValuePair <string, byte[]> file in files) { UnsupportedTypeHandlingEnum unsupportedHandling = GetUnsupportedHandlingFromOptions(options); using (ConversionEngine engine = m_engineFactory.ConstructFileEngine(file.Key, file.Value, unsupportedHandling)) { engine.ConvertToPdf(options); byte[] result = engine.OutputFile; converted.Add(result); } } return(CombinePdfs(converted, options)); }
public ConversionEngineException(string message, string engineProcessOutput, string conversionType, ConversionEngine engine) : this(message, engineProcessOutput, conversionType, engine, null) { }
public ConversionTimeoutException(string message, string engineProcessOutput, string conversionType, ConversionEngine engine) : base(message, engineProcessOutput, conversionType, engine, null) { }
public override ConversionEngine ConstructFileEngine(string fileName, byte[] file, UnsupportedTypeHandlingEnum unsupportedHandling) { if (string.IsNullOrEmpty(fileName)) { throw new MissingSourceException("File not specified."); } ConversionEngine engine = null; switch (Path.GetExtension(fileName).ToLower()) { case ".pdf": engine = new PdfEngine(file); break; case ".png": case ".gif": case ".jpeg": case ".jpg": case ".bmp": engine = new WebKitImageEngine(fileName, file); break; case ".html": case ".htm": engine = new WebKitFileEngine(fileName, file); break; case ".odt": case ".doc": case ".docx": case ".xls": case ".xlsx": case ".ppt": case ".pptx": case ".txt": case ".rtf": engine = new LibreOfficeConversionEngine(fileName, file); break; default: switch (unsupportedHandling) { case UnsupportedTypeHandlingEnum.Error: throw new UnsupportedSourceException("Unsupported file type.", Path.GetExtension(fileName)); case UnsupportedTypeHandlingEnum.NoPage: engine = new NullEngine(); break; case UnsupportedTypeHandlingEnum.PageWithErrorText: engine = new UnsupportedTypeEngine(fileName); break; default: throw new InvalidEnumArgumentException("unsupportedHandling", (int)unsupportedHandling, typeof(UnsupportedTypeHandlingEnum)); } break; } return(engine); }
public UrlFetchException(string[] url, string engineProcessOutput, ConversionEngine engine) : base("Fetch Url(s) failed.", engineProcessOutput, "Url", engine) { }