React-pdf: Doesn't render the PDF from url

Created on 4 Aug 2020  路  3Comments  路  Source: wojtekmaj/react-pdf

Hi @wojtekmaj Thanks for your updates of 5.0.0.0-beta.5
I fixed globalEventBus issue using this version.
But Document component doesn't render the PDF from url.
image

question

Most helpful comment

See simple example displaying first page of PDF: https://github.com/wojtekmaj/react-pdf#usage

As @wojtekmaj mentioned, it's necessary to call
<Page pageNumber={pageNumber} />
for displaying a page of your PDF.

All 3 comments

Here is the code for it.

import React, { useState } from "react";
import { Document } from 'react-pdf';
import Loading from "../Loading";

const PDFViewer = ({ url }) => {
  return (
    <div className="PDFViewContainer">
      <Document
        file={url}
        loading={<Loading />}
      />
    </div>
  );
};

export default PDFViewer;

You're only loading document, but are not displaying any pages. Use Page component as per docs and Wiki.

See simple example displaying first page of PDF: https://github.com/wojtekmaj/react-pdf#usage

As @wojtekmaj mentioned, it's necessary to call
<Page pageNumber={pageNumber} />
for displaying a page of your PDF.

Was this page helpful?
0 / 5 - 0 ratings