WebViewer Version
8.11.0
Do you have an issue with a specific file(s)?
No
Can you reproduce using one of our samples or online demos?
No
Are you using the WebViewer server?
No
Does the issue only happen on certain browsers?
Yes, Chrome Version 113.0.5672.92 (Official Build) (arm64)
Is your issue related to a front-end framework?
No
Is your issue related to annotations?
No
Please give a brief summary of your issue
When highlighting text in a PDF displayed in WebViewer, the text is not copied to the clipboard and the following error is shown in the console.
DOMException: The Clipboard API has been blocked because of a permissions policy applied to the current document.
Please describe your issue and provide steps to reproduce it
I’m initializing the WebViewer like this.
const viewer = await WebViewer(
{
disabledElements: [
'progressModal',
'themeChangeButton',
'toggleNotesButton',
],
licenseKey: '<redacted>',
isReadOnly: true,
path: Utils.requireFromCDN('webviewer'),
preloadWorker: 'pdf',
},
element
)
After that, in the UI, I highlight a portion of text in the PDF and click the Copy icon that shows below my highlighted text. The text is not copied to clipboard.
I also tried programmatically adding the allow
attribute to the iframe rendered by WebViewer to set the Permissions Policy, but that didn’t work.
cont initializeWebViewer = async (element) => {
const iframes = element.getElementsByTagName('iframe')
const viewer = await WebViewer({ ... }, element)
iframes[0]?.setAttribute('allow', 'clipboard-read; clipboard-write')
}
I’ve looked through the WebViewer API documentation for a property that allows copy but could not find one. Is there a property in the config passed upon WebViewer initialization so that the copy functionality works?
Please provide a link to a minimal sample where the issue is reproducible:
Cannot repro