2017-03-07 107 views
1

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

下面是我的HTML代码,查看PDF文档

<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文件。

回答

0

使用PDF.js为您提供了PDF查看器的来源。只需从web/viewer.html中删除这些按钮。

请注意,您的网址将不得不改变,以web/viewer.html?file={{ url('uploads/chapters/Author.pdf') }}作为指定here


要查看MS Office文档,使用类似Zoho

+0

如何使用pdf.js文件我需要文档 – Vinothini

+0

@Vinothini而不是直接链接到PDF本身,通过'file'参数将iframe链接到您的viewer.html页面 – Justinas

+0

我有我的答案见下面 – Vinothini

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>

+0

这不是我想要的实际上我需要显示PDF文件没有打印和下载选项使用iframe标记 – Vinothini

+0

您的意思是隐藏浏览器打印预览的下载和打印选项? – Muhammad

+0

不,文档查看器在html元素中使用iframe – Vinothini

0

我发现了一个解决方案......这里是我得到的解决方案

Hiding the toolbars surrounding an embedded 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>