在 pdf 查看器中禁用复制和打印选项

新手上路,请多包涵

我已经使用标签来显示文档(文件)。在显示带有打印和下载选项的 pdf 文件中,我需要删除 pdf 查看器中的打印和下载选项,是否有任何方法可以隐藏它。

下面是我查看pdf文档的html代码

 <iframe class="iframemargins" src="{{ url('uploads/chapters/Author.pdf') }}"
        title="PDF in an i-Frame" frameborder="0" scrolling="auto" width="100%"
        height="600px">
</iframe>

有没有其他方法可以显示 pdf、doc、txt、rtf 等文件。

原文由 VinoCoder 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 558
2 个回答

我在这里找到了解决方案…这是我找到解决方案的链接

隐藏嵌入式 pdf 周围的工具栏?

我已经更新了我的 html 代码如下和它的工作

<iframe src="{{ url('uploads/chapters/Author.pdf') }}#toolbar=0&navpanes=0&scrollbar=0" title="PDF in an i-Frame" frameborder="0" scrolling="auto" style="width:100%; height:100%;"></iframe>

原文由 VinoCoder 发布,翻译遵循 CC BY-SA 4.0 许可协议

您可以使用打印媒体查询来隐藏打印中的元素。请参见下面的示例。

 var btn = document.getElementById("print");
btn.addEventListener("click", function(){
    window.print();
});
 @media print {
    .print {
        display: none;
    }
}
 <h3 style='text-align: center'>My Table</h3>
<table border='1' style='border-collapse: collapse; width: 100%;'>
<thead>
  <tr>
    <th>Heading 1</th>
    <th>Heading 2</th>
    <th>Heading 3</th>
  </tr>
</thead>
<tbody>
    <tr>
    <th>Value 1</th>
    <th>Value 2</th>
    <th>Value 3</th>
  </tr>
    <tr>
    <th>Value 1</th>
    <th>Value 2</th>
    <th>Value 3</th>
  </tr>
    <tr>
    <th>Value 1</th>
    <th>Value 2</th>
    <th>Value 3</th>
  </tr>
    <tr>
    <th>Value 1</th>
    <th>Value 2</th>
    <th>Value 3</th>
  </tr>
</tbody>
</table>
<button class='print'>Download</button>
<button class='print' id='print'>Print</button>

原文由 Muhammad 发布,翻译遵循 CC BY-SA 3.0 许可协议

推荐问题