Home > OS >  How do I access local PDF files in my Chrome Extension app?
How do I access local PDF files in my Chrome Extension app?

Time:02-08

Google Chrome allows you to preview local PDF files in the browser like pictured below:

enter image description here

I am working on an extension that takes whatever PDF is in the browser preview and opens it in my custom editor/markup tool.

I have been successful in loading PDFs from remote URLs because I can just send the remote URL to my server, download it there, and open the PDF in my app using PDFjs.

How can I accomplish the same functionality for local PDF files?

I have looked into possibly using javascript to create a File object from local PDF files but Chrome doesn't allow access to the local file system.

I am hoping to accomplish this functionality by the user just clicking my extension icon, similar to the popular extension, Kami.

CodePudding user response:

you need to add permissions to your extension:

"permissions": ["file://*/*"]

to ensure that you have permissions for local files, use:

chrome.extension.isAllowedFileSchemeAccess

P.S. have a good day and do not use upwork for these type of questions :-D

  •  Tags:  
  • Related