Submit the password programmatically

By default, the Viewer component will ask users to enter the password when opening a protected PDF document. For any reason that you want to do it programmatically, you can use the onDocumentAskPassword option.
It is triggered when a document requires a password to open. It is also called when a user provides a wrong password. The following example verifies the password programmatically:
import { Viewer } from '@react-pdf-viewer/core';
import type { DocumentAskPasswordEvent } from '@react-pdf-viewer/core';
const handleAskPassword = (e: DocumentAskPasswordEvent) => {
e.verifyPassword('The password goes here');
};
<Viewer onDocumentAskPassword={handleAskPassword} />;