izuzak / atom-pdf-view

Support for viewing PDF files in Atom.
https://atom.io/packages/pdf-view
MIT License
108 stars 30 forks source link

Display PDFs in custom elements #221

Open jneuendorf opened 5 years ago

jneuendorf commented 5 years ago

Hey,

Preamble

I am working on a package where I wan't to display local PDF files -- just like atom-pdf-view. Since I am using React in my package, I figured I'd use react-pdf but I couldn't get it to work...I assume it has something to do with a warning I got (Loading PDF as base64 strings/URLs might not work on protocols other than HTTP/HTTPS. On Google Chrome, you can use --allow-file-access-from-files flag). Since Atom uses the file protocol (check window.location.protocol) I don't know how to get around this problem (I've tried quite some things πŸ˜•), but with atom-pdf-view you somehow do get it to work πŸ˜‰.

So now, I am trying to just indirectly use your package by using Atom's URI opener feature (see atom.workspace.open and atom.workspace.addOpener).

Features Request

For me, it would be really cool if I could use your packages core to display PDFs wherever I want (in the DOM).

My current idea is to have a service provided by atom-pdf-view that other packages can consume. The consumer would get an async function (let's call it renderPdf) that takes a file path or data URI und returns an element (<canvas> I believe but not sure) that contains the rendered PDF.

I am not familiar how updating/scaling works, thus there may be some more options needed to pass onto renderPdf, i.e. the wanted width.

This feature would make your code for displaying PDFs in Atom independent from Atom's file/URI handling and I think this is really nice and powerful. Let me know what you think πŸ˜‰

PS: Thanks for atom-pdf-view πŸ‘

izuzak commented 5 years ago

Thanks for opening an issue for this, @jneuendorf! πŸ’Ÿ Yeah, I think that would be a really really nice feature. That said, I have no idea how much work that would involve. My package uses PDF.js and it somehow just works πŸ˜„. I won't pretend I understand how and why it works -- but it does.

And even if I knew how much work it involved -- I probably won't have time to do the work myself anytime soon.

With that in mind -- if you'd like to take a crack at this, please feel free! I'd be happy to review a pull request and help with testing πŸ‘

jneuendorf commented 5 years ago

Hey @izuzak, thanks for your comment. I would try to look into it but it will probably take some time as I am busy as well. It would be nice to know there are no major changes coming soon, because my changes require some refactoring. πŸ˜‰

izuzak commented 5 years ago

I would try to look into it but it will probably take some time as I am busy as well.

πŸ‘ More time is on my shopping list as well. 😬

It would be nice to know there are no major changes coming soon, because my changes require some refactoring. πŸ˜‰

I'm not going to make any major changes -- I'm not actively working on this package, just doing maintenance as needed (again, due to lack of time).