You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Chrome中通过object标签隐藏PDF侧边栏但保留工具栏的方法

解决PDF渲染隐藏侧边栏但保留工具栏的问题

不同浏览器的PDF渲染引擎支持的哈希参数存在差异,以下是针对主流浏览器的有效方案:

  • Chrome/Edge(PDFium引擎)
    使用#pagemode=none参数,该参数会隐藏侧边栏(包括缩略图、书签等面板),同时默认保留顶部工具栏。如果需要页面宽度适配容器,可搭配view=FitH参数:

    <object
      class="document-preview"
      data="/path/to/the_file.pdf#pagemode=none&view=FitH"
      style="border: none;"
      width="100%"
      height="650"
      type="application/pdf"
    >
      <p>Sorry, this document could not be displayed.</p>
    </object>
    
  • Firefox(PDF.js引擎)
    使用#sidebar=hidden参数,可单独隐藏缩略图侧边栏,同时保留顶部工具栏:

    <object
      class="document-preview"
      data="/path/to/the_file.pdf#sidebar=hidden"
      style="border: none;"
      width="100%"
      height="650"
      type="application/pdf"
    >
      <p>Sorry, this document could not be displayed.</p>
    </object>
    

为了兼容多浏览器,可以组合两个参数,让不同引擎各自识别对应的参数:

data="/path/to/the_file.pdf#pagemode=none&sidebar=hidden"

内容的提问来源于stack exchange,提问作者Max Williams

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 22:37:08