PDF.js Read Only is an additional readonly mode for PDF.js

Overview

PDF.js Read Only

PDF.js Read Only is an additional readonly mode for PDF.js, a Portable Document Format (PDF) viewer that is built with HTML5 which is community-driven and supported by Mozilla.

Its purpose to make PDF.js viewer to be readonly mode, including disable right click on mouse (context menu) and several hotkeys (keyboard shortcut) such as:

  • Ctrl + C (Copy Text)
  • Ctrl + O (Open PDF)
  • Ctrl + P (Print PDF)
  • Ctrl + S (Save PDF)
  • PrtSc       (Print Screen) (experimental)

Demo

  1. PDF.js without read only  /generic/web/viewer.html
  2. If using PDF.js Read Only /generic/web/viewer_readonly.html

How to use

  1. /generic/web/viewer_readonly.html
    adjustment in viewer_readonly.html
    --> ">
    
     
     
     
    
  2. /js/pdf.js_readonly.js
    adjustment in pdf.js_readonly.js
    // Read Only Preferences
    var disableRghtClck = true; // Disable Right Click,   value: true || false
    var disableCopyText = true; // Disable Copy Text,     value: true || false
    var disableOpenFile = true; // Disable Open PDF,      value: true || false
    var disablePrintPdf = true; // Disable Print PDF,     value: true || false
    var disableDownload = true; // Disable Save PDF,      value: true || false
    var disablePrntScrn = true; // Disable Print Screen,  value: true || false (experimental)
    
    // Load Specific viewer.js
    if ( disablePrintPdf ) {
      $.getScript( '../../js/viewer_noprint.js' ); // Adjust path to viewer_noprint.js if necessary
    } else {
      $.getScript( 'viewer.js' );  // Adjust path to viewer.js if necessary
    }
    
  3. /js/viewer_noprint.js
    modification from viewer.js
    /*  Modified for PDF.js Read Only
     *  To disable print overlay
     */
    /* window.addEventListener("keydown", function (event) {
      if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
        window.print();
        event.preventDefault();
    
        if (event.stopImmediatePropagation) {
          event.stopImmediatePropagation();
        } else {
          event.stopPropagation();
        }
      }
    }, true); */
    
    Note: If you want to create viewer_noprint.js on your own from viewer.js file of your current PDF.js version, make sure those lines above (or some codes like that) are commented.
You might also like...

I'm trying to create simple program for adding the digital signature to a pdf file with self-signed certificate. I use node-signpdf and pdf-lib library.

pdf-digital-signature-with-node-signpdf-ejs I'm trying to create simple program for adding the digital signature to a pdf file with self-signed certif

Dec 25, 2022

An application that has a frontend (user interface) that allows you to create, read, update or delete (CRUD) products using an API in which you can also create, read, update or delete products.

An application that has a frontend (user interface) that allows you to create, read, update or delete (CRUD) products using an API in which you can also create, read, update or delete products.

CRUD app with React and Firebase 9 An application that has a frontend (user interface) that allows you to create, read, update or delete (CRUD) produc

Sep 28, 2021

Interactive web app where you can Store ,Add and Remove books to organize the books that you've read or the ones willing to read

bookStore Interactive web app where you can Store ,Add and Remove books to organize the books that you've read or the ones willing to read Built With

Jul 20, 2022

Read without losing the plot. Well Read helps you organize your notes about books you're reading, so you're never lost when starting a new volume.

Read without losing the plot. Well Read helps you organize your notes about books you're reading, so you're never lost when starting a new volume.

Well Read Well Read is a website for tracking your reading of long book series. I made this to track how many pages I read in a session and to better

Dec 15, 2022

An online library for adding and removing a different number of books from a user collection, keeping track of the books you've read and the one's you are yet to read

An online library for adding and removing a different number of books from a user collection, keeping track of the books you've read and the one's you are yet to read

Awesmoe Books A Website demo for our project of book store, The website has ability of adding and removing you books from yor library, Thats reflects

Jul 8, 2022

A little JavaScript plugin to generate PDF, XLS, CSV and DOC from JavaScript Object or DOM element only from the frontend!

💫 JavaScript Object to csv, xls, pdf, doc and DOM to html generator 💫 A little JavaScript plugin to generate PDF, XLS, CSV and DOC from JavaScript O

Jan 7, 2023

Serve read-only Redis data over a HTTP API with auth

Redis data exposer This was created for Cliptok and not intended for use outside of it. Use at your own peril. This application will serve an API that

May 28, 2022

🌈 GitHub following, followers, only-following, only-follower tracker 🌈

🌈 GitHub following, followers, only-following, only-follower tracker 🌈

github-following-tracker GitHub following, followers, only-following, only-follower tracker 👀 Just enter your GitHub name and track your followings!

Jun 15, 2022

Drop-in replacements for @apollo/client's useQuery, useMutation and useSubscription hooks with reduced overhead and additional functionality.

apollo-augmented-hooks Drop-in replacements for @apollo/client's useQuery, useMutation and useSubscription hooks with reduced overhead and additional

Nov 18, 2022

Windows notepad in web with additional features! Made with typescript and react.

Windows notepad in web with additional features! Made with typescript and react.

Notepad Windows notepad in web with additional features! 📝 Table of Contents 🧐 About Why I created ? Helpful for ? Who can contribute ? 🏁 Getting S

Jan 3, 2023

A simple and responsive quizlet-like flashcard component with a few additional options

A simple and responsive quizlet-like flashcard component with a few additional options

Welcome to react-quizlet-flashcard 👋 A simple and responsive quizlet-like flashcard component with a few additional options. Front and back card acce

Dec 17, 2022

A platform designed specifically as an additional layer on top of Google Classroom for students to gain the best out of online evaluations

A platform designed specifically as an additional layer on top of Google Classroom for students to gain the best out of online evaluations

Peer-Learning-Platform A platform designed specifically as an additional layer on top of Google Classroom for students to gain the best out of online

Jun 12, 2022

Additional themes for Lovelace Mushroom Cards 🍄

Additional themes for Lovelace Mushroom Cards 🍄

🍄 Mushroom Themes Mushroom themes allow you to customize your Mushroom dashboard using Home Assistant themes. ⚠️ It's only a theme! You need to insta

Dec 24, 2022

A collection of some additional input types to use with FormKit

A collection of some additional input types to use with FormKit. Most of these additional input types are based on my personal needs, but feel free to submit PRs to add more.

Jan 2, 2023

A NodeJs service which allows you to create a movie based on it's title (additional movie details will be fetched) and fetch all created movies.

movies-api A NodeJs service which allows you to create a movie based on it's title (additional movie details will be fetched) and fetch all created mo

Mar 27, 2022

Used for creating a out-of-the-box template without additional configuration.

ou Used for creating a out-of-the-box template without additional configuration. Templates Vue3 Lite Template Used for some simple web app Vue3 + Vite

Jul 17, 2022

A recreation of the popular game Wordle with additional modes and features. Made with Svelte in Typescript.

A recreation of the popular game Wordle with additional modes and features. Made with Svelte in Typescript.

A recreation of the popular game Wordle by Josh Wardle (now purchased by the New York Times), with additional modes and features. Hosted on GitHub pag

Dec 11, 2022

An obsidian plugin that give additional features to code blocks.

An obsidian plugin that give additional features to code blocks.

Obsidian Advanced Codeblock Add additioinal features to code blocks. Demo Feature Add line numbers to code block Add line highlight to code block Usag

Jan 3, 2023

A set of utilities and additional features for my creative coding class aiming to help students while introducing the algorithmic thinking.

A set of utilities and additional features for my creative coding class aiming to help students while introducing the algorithmic thinking.

p5.utils A set of utilities and additional features for my creative coding class aiming to help students while introducing the algorithmic thinking. T

Dec 25, 2022
Comments
  • Using minified PDF.js files possible?

    Using minified PDF.js files possible?

    Hi, I really like this code that you have shared - it has made it very easy to integrate a readonly version of pdf.js.

    Would it be possible to use a minified version of pdf.js? I was reading the FAQ in the main repository - and it seems like it should be possible.

    Could you guide me on the process to use the minified files (i.e which files do I replace with minified ones) ?

    question 
    opened by amrithyerramilli 1
Owner
Aprillio Latuminggi
Aprillio Latuminggi
A lib for loading PDF in Android using WebView

A lib for loading PDF in Android using WebView Usage Including in your project Copy... /pdf/src/main/assets/... all files in the path Use val settings

fuusy 197 Jan 4, 2023
Bionic ReadingTool - Convert Text into Better Way to Read Faster

?? Bionic ReadingTool A revolutionary way for guiding the eyes through text using artificial fixation spots to make reading easier. As a result, the r

Lucian Daniel Crisan 335 Dec 24, 2022
Jenesius vue modal is simple library for Vue 3 only

Jenesius Vue Modal Jenesius vue modal is simple library for Vue 3 only . Site Documentation Installation npm i jenesius-vue-modal For add modals in yo

Архипцев Евгений 63 Dec 30, 2022
Try Vant in the Playground. Currently only Vant 3+ is supported

SFC Playground with Vant This is an Vant SFC Playground. Detail vercel.app Or zhixiaoqiang.github.io NOTE! The reason why this is designed to manually

jzone 16 Dec 14, 2022
Table of contents Trilium widget for editable and readonly text notes.

Trilium-TocWidget Table of contents Trilium widget for editable and readonly text notes. Screenshot Features The ToC is live and automatically updated

Antonio Tejada 25 Dec 29, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
MDN-Dark-Mode - Simple extension to add a dark mode with different themes to the MDN Web Docs website

MDN-Dark-Mode Information Chrome and Firefox extension that adds a dark mode wit

Santiago Galán Barlo 2 Mar 18, 2022
🌓 Add dark mode/night mode custom elements to your website.

dark-mode A custom element that allows you to easily put a Dark Mode ?? toggle. so you can initially adhere to your users' preferences according to pr

小弟调调™ 12 Oct 20, 2022