Ritu Singh
Solution:
You can use GhostScript.net which supports memory streams (nonphysical files).
However, this will be a hard task to do in real time as GS takes a lot of chunks of your CPU. Plus, the process of converting PDF to image is also a huge task. This is especially true for larger PDFs. The conversion of a PDF to a raw byte image may occasionally take several seconds, even for a one-page document if the page is larger.
Therefore, it would be a good idea to process the PDF files before attempting to display such preview images on your website, as the above suggests. I save the image (raw byte jpeg image) to a database and use this for PDF thumbnails.
You can do this in real time if there is only one image to be shown on the page. Preprocessing the PDF to image previews is what I advise when there are several images on a page.
But let's say we have a PDF file. We want to show the first page of the PDF as an image, but we don't want to create an image file on disk for that.
So, we have this markup:
Thus, the webpage only has a button and an image.
Thus, let's show a thumbnail (image) for a given PDF file without generating a file (memory stream).
So, the code behind is this:
And the result is thus this:
The above concept shows how you can create a PDF image preview 100% in memory.
Suggested blogs:
>>Step by Step guide to Deploy Terraform in Azure using GitHub Actions
>>Testing react components using Hooks and Mocks
>>How to destroy a custom object within the use Effect hook in TypeScript?
>>Create a function that convert a dynamic Json to a formula in Typescript
>>Narrow SomeType vs SomeType[]
>>Use Firebase Realtime Database with ASP.NET MVC App
>>Use of Singletons in .NET Core in AWS Lambda
>>How to do PHP Decryption from Node.js Encryption