pdfrx_web
    Preparing search index...

    Function usePdfDocument

    • Load state and identity of the current document.

      Re-renders when the document changes and while it is downloading, so this is what a progress bar, a page count, or an error banner should read from.

      Returns PdfDocumentState

      The current pdf document state and actions.

      const { isLoading, progress, pageCount, error } = usePdfDocument();
      if (error) return <p>Failed to open: {String(error)}</p>;
      if (isLoading) return <progress value={progress?.bytesReceived} max={progress?.bytesTotal ?? undefined} />;
      return <p>{pageCount} pages</p>;