PDF how to take a snapshot snapshot?

When a user uploads a PDF or Word ms document, I would like to take a snapshot of the first page and display it as an image, how to do it?

+4
source share
3 answers

Try this article: How to convert PDF to image formats in .NET . It shows how to create snapshots of PDF pages using our PDFOne.NET product.

DISCLAIMER: I work for the Gnostis.

+3
source

Use ImageMagick Application Wrapper and
convert.exe 'file.pdf[0]' snapshot.jpg

0
source

For Word documents, you need a solution that can understand and take a picture. You can use TxTextControl or some Word printer driver, such as Easy PDF Creator.

Once you have the PDF file ready, you can use Super Pdf2Image Converter.NET . It is available for both 32 and 64 bit and is very cheap and efficient.

You can look here: http://softwaresigloxxi.com/SuperPdf2ImageConverter.html

For example, here is a sample code for conversion:

 // Instantiate the component Pdf2ImageConverter p2i = new Pdf2ImageConverter(pdfPath); // Get page count of a PDF file int pages = p2i.GetPageCount(); // Get size of any page int width, height; p2i.GetPageSize(1, out width, out height); // Convert any page of PDF to image file (preserving aspect ratio) p2i.GetImage(outputImagePath, pageNumber, resolution, imageFormat); // Or... convert any page of PDF to image (returns bitmap object) Bitmap bm = p2i.GetImage(pageNumber, resolution, width, height, imageFormat); 

(Disclaimer I worked on this component in Software Siglo XXI)

0
source

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


All Articles