Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

333
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda