Ejemplo n.º 1
0
        public Image Rasterize(Stream data, string type)
        {
            Stream stream = new MemoryStream();

            switch (type)
            {
            case ".doc":
            case ".docx":
                Document doc = new Document(data);
                doc.Save(stream, Aspose.Words.SaveFormat.Pdf);
                break;

            case ".xls":
            case ".xlsx":
                Workbook workbook = new Workbook(data);
                workbook.Save(stream, Aspose.Cells.SaveFormat.Pdf);
                break;

            case ".ppt":
            case ".pptx":
                Presentation ppt = new Presentation(data);
                ppt.Save(stream, Aspose.Slides.Export.SaveFormat.Pdf);
                break;
            }

            PdfRasterizer pdfRasterizer = new PdfRasterizer();
            var           img           = pdfRasterizer.Rasterize(stream, "pdf");

            return(img);
        }
Ejemplo n.º 2
0
        public System.Drawing.Image Rasterize(Uri uri)
        {
            string appBinFolder = AppDomain.CurrentDomain.BaseDirectory + @"bin";

            var path = GlobalProperties.HtmlEngineFullPath = Path.Combine(appBinFolder, "Select.Html.dep");

            HtmlToPdf   converter = new HtmlToPdf();
            PdfDocument doc       = converter.ConvertUrl(uri.AbsoluteUri);

            var stream = new MemoryStream();

            doc.Save(stream);
            stream.Seek(0, SeekOrigin.Begin);

            PdfRasterizer pdfRasterizer = new PdfRasterizer();
            var           image         = pdfRasterizer.Rasterize(stream, "pdf");

            return(image);
        }