Exemplo n.º 1
0
        public ActionResult GetDocumentThumbnail(int id)
        {
            string doctype   = "image/jpg";
            var    imageData = DMLObj.GetDocDataById(id, out doctype);

            if (doctype.ToLower() == "application/pdf")
            {
                Spire.Pdf.PdfDocument document = new Spire.Pdf.PdfDocument();
                document.LoadFromStream(new MemoryStream(imageData));
                Image ImgDoc = document.SaveAsImage(0, Spire.Pdf.Graphics.PdfImageType.Bitmap, 120, 120);
                return(File(imageToByteArray(ImgDoc.ScaleImage(150, 150)), "image/jpeg"));
            }

            //if (doctype.ToLower() == "application/msword")
            //{
            //    Spire.Doc.Document document = new Spire.Doc.Document();
            //    document.LoadFromStream(new MemoryStream(imageData),Spire.Doc.FileFormat.Doc);
            //    Image ImgDoc = document.SaveToImages(0, Spire.Doc.Documents.ImageType.Metafile);
            //    return File(imageToByteArray(ImgDoc.ScaleImage(150, 150)), "image/jpeg");
            //}

            //if (doctype.ToLower() == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
            //{
            //    Spire.Doc.Document document = new Spire.Doc.Document();
            //    document.LoadFromStream(new MemoryStream(imageData), Spire.Doc.FileFormat.Docx2010);
            //    Image ImgDoc = document.SaveToImages(0, Spire.Doc.Documents.ImageType.Metafile);
            //    return File(imageToByteArray(ImgDoc.ScaleImage(150, 150)), "image/jpeg");
            //}
            return(File(imageData, doctype));
        }