Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

33
Vistas
Download PDF from link and display it

I have backend link which I click (or pass it to tag) it starts downloading. How can I display i? I dont want users to be able to download it, just want to display it in my react component.

I already tried something like this:

   async function createFile(url) {
    let response = await fetch(url);
    let data = await response.blob();
    let metadata = {
      type: "application/pdf",
    };
    let file = new File([data], "12121.pdf", metadata);
    return file;
  }

  const [file, setFile] = useState();

  useEffect(() => {
    if (pdf) {
      setFile(createFile(pdf));
    }
  }, [pdf])

and then i tried to display it by

 <embed src={file} width="800px" height="2100px" />

but it doesnt seems to work..

7 months ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos