상속: IDisposable
 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;
 }
예제 #2
0
 public byte[] ConvertText(string text, ConversionOptions options)
 {
     using (ConversionEngine engine = m_engineFactory.ConstructTextEngine(text))
     {
         engine.ConvertToPdf(options);
         return(engine.OutputFile);
     }
 }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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, Exception innerException)
     : base(message, innerException)
 {
     this.ConversionType      = conversionType;
     this.EngineName          = engine.GetType().Name;
     this.EngineProcessOutput = engineProcessOutput;
 }
 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)
 {
 }
예제 #10
0
        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 ConversionTimeoutException(string message, string engineProcessOutput, string conversionType, ConversionEngine engine)
     : base(message, engineProcessOutput, conversionType, engine, null)
 {
 }
 public ConversionEngineException(string message, string engineProcessOutput, string conversionType, ConversionEngine engine)
     : this(message, engineProcessOutput, conversionType, engine, null)
 {
 }
예제 #13
0
 public UrlFetchException(string[] url, string engineProcessOutput, ConversionEngine engine)
     : base("Fetch Url(s) failed.", engineProcessOutput, "Url", engine)
 {
 }
예제 #14
0
 public UrlFetchException(string[] url, string engineProcessOutput, ConversionEngine engine)
     : base("Fetch Url(s) failed.", engineProcessOutput, "Url", engine)
 {
 }