简体   繁体   中英

Hide pdf toolbar with pdfjs with laravel 5

Please I need to be guided on how to remove the pdf toolbar from a pdf document I dynamically display on a page on my website to discourage printing and downloading of the document from the website.

This is the toolbar 在此处输入图片说明

On web.php route page, I have the following route

Route::get('showresource/{id}','ResourceController@show');

Which returns the file and is then displayed in the following blade page

    <object data="{{url('showresource/'.$current_lesson->resource_file)}}" type="{{$mime_type}}" height="600px" width="100%" id="resource-pdf" style=""></object>

I have added the following javascript to the page to no avail.

$(document).ready(function () {
  $('#resource-pdf').contents().find('#toolbar').css('display','none');
   });

This does not seem to be working.

I have also tried to use pdfjs but I don't know how to apply it to a laravel 5 project. I look forward to any support to solve this.

Thank you

In my case (chrome-based web browser) this bar is a <viewer-pdf-toolbar> HTML tag. If you add to your css file or between <style> tag this code

viewer-pdf-toolbar {
  display: none !important;
}

The bar will disappear. Don't do this by inline method because this tag is often overwritten by web browser. My way is tested and works perfect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM