居中嵌入PDF内容 [英] Centering embed PDF content
问题描述
我的网页中嵌入了PDF文件。我的HTML是:
< embed src =http://znaci.net/zb/4_1_19.pdf>
我的CSS是:
嵌入{
width:500px;
height:600px;
}
现在我遇到这样的情况:
但是我需要这个:
有没有一种方法可以集中嵌入PDF内容?
您可以通过CSS来控制高度和宽度:
<风格>
嵌入{
width:100%;
height:500px;
}
< / style>
您也可以通过嵌入
标记,例如:
< embed src =http://znaci.net/zb/4_1_19.pdfwidth =640height =480>
至于缩放,您可以通过执行以下操作来实现此目的(请注意#zoom = 75) :
< embed src =http://znaci.net/zb/4_1_19.pdf#zoom=75> ;
此语法适用于IE11和FF32,但不适用于Chrome 38。 b
编辑:回答问题的核心部分:
居中PDF仅失败在Chrome中。解决这个问题的方法可以是用这样的iFrame替换嵌入
标记(尽管我不认为这是最佳做法)。
< iframe src =http://znaci.net/zb/4_1_19.pdf>< / iframe>
或者,你可以看一些像 pdf.js 。
I have a PDF file embed inside my web page. My HTML is:
<embed src="http://znaci.net/zb/4_1_19.pdf">
My CSS is:
embed {
width:500px;
height:600px;
}
Now I have a situation like this:
But I need this:
Is there a way to center embed PDF content?
You can control the height and width via CSS like such:
<style>
embed {
width: 100%;
height: 500px;
}
</style>
You also control it via attributes in the embed
tag like such:
<embed src="http://znaci.net/zb/4_1_19.pdf" width="640" height="480">
As for the zoom, you can achieve this by doing the following (note the #zoom=75):
<embed src="http://znaci.net/zb/4_1_19.pdf#zoom=75">
This syntax worked in IE11 and FF32, but not in Chrome 38.
Edit: Answer to the centering part of the question:
Centering the PDF only fails in Chrome. A work around for this can be to replace the embed
tag with an iFrame like such (though I don't think this is the best practice).
<iframe src="http://znaci.net/zb/4_1_19.pdf"></iframe>
Alternatively, you can look at some thing like pdf.js.
这篇关于居中嵌入PDF内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!