I have an ASP.NET WebForms application (written in C#) that allows users to upload files using the FileUpload control.
What'd be great is if I could automatically generate thumbnails from files. Images such as JPG/PNG are trivial of course, but users will often upload .DOC and .PDF files - is there a way I can essentially convert .DOC and .PDF files to images so I can get a thumbnail?
Thanks!
You can use GhostScriptWrapper
for generating image thumbnails directly from pdf.You can get ghostScriptWrapper
from GitHub or you can include ghostscript.dll
from nuget package manager solution.
On paper the most hopeful approach would be to do so server side. So, if the file were uploaded, the server could generate a preview image.
On Windows, there would be a few options.
a) Windows Shell has a way to do it. The path is dangerous though. b) https://filepreviews.io/ Is a service that does it, but they charge. c) box is another service that does it.
Now on Linux, or even, perhaps, a Linux in a Windows subsystem, could do it with some command line utilities.
a) Convert the doc to pdf:
Convert DOC to PDF
b) Then, get a bitmap of the first page of the pdf, use ghostscript. ghostscript also exists for .NET and Windows.
Bitmap of PDF First Page
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With