Convert from PDF and words to images

The requirement is to show a thumbnail of all documents, such as pdf and ms-words, we store the documents in a database, we need to convert them to a file stream and display them as thumbnails.

At the moment I can display the image, because it is straightforward, I also have to display pdf images and text documents. I will show how I do for images

Controller:

public ActionResult File(int id) { var fileToRetrieve = db.File.Find(id); return File(fileToRetrieve.Content, fileToRetrieve.ContentType); } 

View:

  @foreach (var item in Model) { <div class="form-group"> <img src="~/Home/ File?id=@item.FileId " alt="avatar" width="100px" height="100x" /> </div> } 
+5
source share
1 answer

Need ImageMagick and GhostScript

 <?php $im = new imagick('file.pdf[0]'); $im->setImageFormat('jpg'); header('Content-Type: image/jpeg'); echo $im; ?> 

[0] means page 1.

0
source

Source: https://habr.com/ru/post/1260876/


All Articles