Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

334
Vistas
How to print pdf in chrome but make text inside pdf unselectable?

I need to download the pdf of html page for which i have used chrome builtin, printing feature to save as pdf. However, I don't want my users to be able to simply copy paste the text, No matter if they use image ocr to extract text, they should not be able to easily copy text, how to make this possible?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

A easy / fast solution is to use 'html2canvas' (link to website). You just would have to add the parameter canvas with the value true to the printThis config-parameter, so that it works.

The code would look like this:

   html2canvas(document.querySelector("#page")).then(canvas => {
       $(canvas).printThis({ canvas: true })
   });

Where the html - Element with the idof #page contains the html you want to print/convert to pdf. With other words, it is the same element, on which you would call the printThis function.

Here a JsFiddle: https://jsfiddle.net/vwfb20sp/

window.addEventListener('DOMContentLoaded', _ =>
     html2canvas(document.querySelector('#page'))
     .then(canvas => {
         document.body.appendChild(canvas)
         $('#page').printThis({ 
                canvas: true 
         })
     })
);
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js">
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/printThis/1.15.0/printThis.min.js">
</script> 
<body >
    <div id ="page">
        test
        <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/89/Amber_mountain_rock_thrush_%28Monticola_sharpei_erythronotus%29_male_2.jpg/1200px-Amber_mountain_rock_thrush_%28Monticola_sharpei_erythronotus%29_male_2.jpg" alt="Amber mountain rock thrush (Monticola sharpei erythronotus) male 2.jpg" />
    </div>
</body>
about 4 years ago · Juan Pablo Isaza Denunciar

0

There is generally no way to dictate how your server clients should behave. so using the example above IF I wish to change the server text or image outputs for my accessibility, such as Reading or text preferences, I can use the browser control of a server offerings like this:-

enter image description here

HTTPS is dis(re)position of hyper text from one ownership to another, The server may pr-offer objects but the client may refuse images (or other content like adverts) and adapt the server offerings to their own tastes.

When using browser for pdf the editor is the clients owned server

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda