wojtekmaj / react-pdf

Display PDFs in your React app as easily as if they were images.
https://projects.wojtekmaj.pl/react-pdf
MIT License
9.01k stars 861 forks source link

onRenderAnnotationLayerSuccess callback executing before the annotation layer is rendered on the screen #1740

Closed Talha345 closed 2 weeks ago

Talha345 commented 4 months ago

Before you start - checklist

Description

Hi,

I have tried using the onRenderAnnotationLayerSuccess and onRenderSuccess callbacks as I want to execute a function after the annotationLayer has rendered on my screen, however onRenderAnnotationLayerSuccess callback is executed before the paint is completed on the screen. The documentation says: "Function called when annotations are successfully rendered on the screen.", however this is not happening in my scenario.

Steps to reproduce

  1. Clone the react-pdf library
  2. Go to sample/vite/ folder and install the demo dependencies npm install
  3. Run the demo:npm run dev
  4. Go to the file sample/vite/Sample.tsx
  5. Update the page component call to:

              function test(): void {
                  alert("Annotation Layer Rendered");
              }
    
              <Page
                key={`page_${index + 1}`}
                pageNumber={index + 1}
                width={containerWidth ? Math.min(containerWidth, maxWidth) : maxWidth}
                renderAnnotationLayer={true}
                renderForms={true}
                onRenderAnnotationLayerSuccess={test}
              />

The alert will be shown before the document is displayed on the screen.

Expected behavior

The onRenderAnnotationLayerSuccess function should be executed once the annotation layer is completed rendered on the screen. Same for onRenderSuccess.

Actual behavior

The onRenderAnnotationLayerSuccess function is executed before the DOM is rendered on the screen.

Additional information

No response

Environment

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

github-actions[bot] commented 2 weeks ago

This issue was closed because it has been stalled for 14 days with no activity.