缩放PDF以适合iFrame

Luu*_*ter 13 html css pdf zoom scale

我需要缩放PDF文件以适应iFrame.它需要响应,因此PDF应该与设备宽度一起缩放,以便PDF文档显示完整的页面.

如果在Bootstrap中有一个免费的插件或函数来实现这一点,我会很高兴听到它.

提前致谢!

小智 27

如果您问如何调整PDF大小以适合Iframe.

以下代码可能有所帮助:

<iframe src="name.pdf#zoom=50" height="100%" width="100%"></iframe>
Run Code Online (Sandbox Code Playgroud)

通过添加#zoom=50它将显示PDF格式,默认情况下在iframe中放大.(这可以编辑成你想要的任何数字)

  • 这适用于 chrome 以及使用 URL.createObjectUrl(blob) 制作的 blob。即 URL.createObjectURL(blob) + '#zoom=FitW' (FitW 适合我的特定需求的宽度,这是我从下面 kuz1toro 的答案中得到的)。 (2认同)

小智 6

在 Firefox 中对我来说它是这样工作的,但不要在其他设备上测试它

<iframe src="filename.pdf#zoom=FitH" style="position:absolute;right:0; top:0; bottom:0; width:100%;"></iframe>
Run Code Online (Sandbox Code Playgroud)