jQuery 以 HTML 格式生成 PDF 文件的缩略图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29375233/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Generate a thumbnail of PDF file in HTML
提问by Gus de Paula
I need to generate a thumbnail of PDF file in HTML. Now I use:
我需要用 HTML 生成 PDF 文件的缩略图。现在我使用:
<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?
如何在此 PDF 上设置大小(191x207px)?
回答by DarthVanger
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.
width="191"
告诉浏览器将宽度设置为 191 像素。
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?
不过,此方法会加载整个 pdf,而不仅仅是缩略图。对于自动缩略图生成,您可以按照此处所述使用 PHP如何在PHP 中将 PDF 文档转换为预览图像?
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:
或者您可以手动创建缩略图,然后将其作为带有 pdf 文件链接的图像添加到您的网站上:
<a href="http://example.com/mydocument.pdf">
<img src="http://example.com/mydocument-thumbnail.jpg" />
</a>