Search code examples
react-pdf

Is there a way to disable `user-select: none` in react-pdf?


I would like to allow users to copy and paste text from PDF documents. However when I inspect the page (with Chrome dev tools) where we are rendering the PDF document, I notice there are styles that set user-select to none. I can't find anything in the react-pdf documentation that indicates how to allow users to select text. Hoping someone knows how!

Here are the CSS rules that are defined on .react-pdf__Document > div > div > div. We could certainly override it with !important but I'm hoping there's another way.

{
    position: absolute;
    inset: 10px 20px;
    height: 1229.41px;
    width: 950px;
    user-select: none;
}

Solution

  • you can manually add user-select: none to the following class:

    .react-pdf__Page__textContent
    

    This works for me