Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate a thumbnail of PDF file in HTML

I need to generate a thumbnail of PDF file in HTML. Now I use:

<embed width="100%" height="100%" name="plugin" src="http://localhost:54149/Documento/VersaoView?chave=FDC4875EE17FB17B" type="application/pdf">

How can I set the size(191x207px) on this PDF?

like image 333
Gus de Paula Avatar asked Mar 31 '15 17:03

Gus de Paula


People also ask

How do I make a PDF a thumbnail in HTML?

Step 1: Create the thumbnail pane using the HTML. Step 2: Sending AJAX request to create the thumbnail images in the server-side and in the success of the AJAX request, PDF Viewer will be initialized.

How do you show preview of a document in HTML?

For single html file, in VS 2022, you can click File > View in Browser (Ctrl + Shift + W) to preview it(or right-click the white space of this single html file > click View in Browser ).

Can I iframe a PDF?

Since the path accepts an embed parameter, you can embed the PDF viewer in your document with iframes.


1 Answers

You can just change those "width" and "height" parameters to values you want:

<embed width="191" height="207" name="plugin" src="http://localhost:54149/Documento/VersaoView?chave=FDC4875EE17FB17B" type="application/pdf">

width="191" tells browser to set width to 191 pixels.

This method loads the whole pdf though, not just a thumbnail. For automatic thumbnails generation, you might use PHP as described here How do I convert a PDF document to a preview image in PHP?

Or you could just create a thumbnail image manually, and then add it on your website as an image with link to the pdf file:

<a href="http://example.com/mydocument.pdf">
    <img src="http://example.com/mydocument-thumbnail.jpg" />
</a>
like image 104
DarthVanger Avatar answered Oct 17 '22 08:10

DarthVanger