better use image processor plugin - Install-Package ImageProcessor.Plugins.PDF
Generate thumnbnail for pdf files, thumbanil created on upload in media for first usage via helper
Installation
Install-Package MissingCode.Umbraco.PdfThumbnail
@using MissingCode.Umbraco.PdfThumbnail;
<img src="@Umbraco.TypedMedia(1117).GetPdfThumbnails()" />