要求是显示所有文件的缩略图,如pdf和ms-word,我们正在数据库中存储的文件,我们需要将其转换为文件流,并必须显示为缩略图图像。
作为现在我能够显示图像,因为它是直截了当的,同样我将不得不显示pdf和word文档的图像。我将展示我是如何处理图像的
控制器:
public ActionResult File(int id)
{
var fileToRetrieve = db.File.Find(id);
return File(fileToRetrieve.Content, fileToRetrieve.ContentType);
}查看:
@foreach (var item in Model)
{
<div class="form-group">
<img src="~/Home/File?id=@item.FileId" alt="avatar" width="100px" height="100x" />
</div>
}发布于 2017-02-03 10:44:40
您需要ImageMagick和GhostScript
<?php
$im = new imagick('file.pdf[0]');
$im->setImageFormat('jpg');
header('Content-Type: image/jpeg');
echo $im;
?>意思是第1页。
https://stackoverflow.com/questions/40996313
复制相似问题