Hello, How do I display a PDF but prevent it from downloading?

72 Views Asked by At

when i was using nextjs and react-pdf but i faild to prevent medium user to download it because his able to go to the google tools inn the goole chrome and find the link of pdf inside network of goole dev tools This is my pdfviewer.tsx page :

"use client"
import { useEffect } from 'react';
import {Document, Page, pdfjs} from 'react-pdf';

interface PdfViewerProps{
    pdfUrl:string;
}
const  PDFpage:React.FC<PdfViewerProps> =({pdfUrl})=>{
    useEffect(() => {
        pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.js`;
      }, []);
      return (
        <Document
        file={pdfUrl}
        >
            <Page pageNumber={1}/>
            <Page pageNumber={2}/>

        </Document>
      )
}
export default PDFpage
1

There are 1 best solutions below

2
K J On

The World Wide Web is "MIME (email) on steroids". You want people to read your wares, so you place it PO Boxes with IP monetized (advertized) by Google addresses. Then if they wish they visit the PO Box and "dis-position" the data to home for reading at leisure, especially when the web is jittery.

All files (HTML PDF Etc.) are binary bytes and have to be HyperTEXTTransPorted:// from server to user. I.e. SENT via Get/Fetch.

Thus from the starting editable binary, via editable text, to browsing editor to edit onto screen as pixels or audio or used for annotation, a PDF is always in flux.

Every PDF is constantly being edited. That is what computers data is designed to do.

So can you personally use a PDF without "download"? Yes only if you don't publish by never offering a HTTP link.

Can you stop it being edited? Only by not allowing it to be opened except by yourself, as editor.