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?
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.
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 ).
Since the path accepts an embed parameter, you can embed the PDF viewer in your document with iframes.
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>
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