<p>要在 HTML 中加载 PDF 文件,可以使用 <embed> 标签或 <object> 标签。</p>
<p>使用 <embed> 标签:</p>
<pre><code class="language-html">&lt;embed src=&quot;example.pdf&quot; type=&quot;application/pdf&quot; width=&quot;100%&quot; height=&quot;600px&quot; /&gt;
</code></pre>
<p>使用 <object> 标签:</p>
<pre><code class="language-html">&lt;object data=&quot;example.pdf&quot; type=&quot;application/pdf&quot; width=&quot;100%&quot; height=&quot;600px&quot;&gt;
  &lt;p&gt;无法加载 PDF 文件,请&lt;a href=&quot;example.pdf&quot;&gt;点击此处&lt;/a&gt;下载。&lt;/p&gt;
&lt;/object&gt;
</code></pre>
<p>在这两个示例中,src 或 data 属性指定要加载的 PDF 文件的 URL。type 属性指定文件的 MIME 类型为 application/pdf。width 和 height 属性指定嵌入式 PDF 文件的宽度和高度。如果 PDF 文件无法加载,则可以在 <object> 标签之间添加替代文本。</p>
html 加载pdf

原文地址: https://www.cveoy.top/t/topic/ef3U 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录