Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display PDFs in custom elements #221

Open
jneuendorf opened this issue Mar 13, 2019 · 3 comments
Open

Display PDFs in custom elements #221

jneuendorf opened this issue Mar 13, 2019 · 3 comments

Comments

@jneuendorf
Copy link

jneuendorf commented Mar 13, 2019

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
Copy link
Owner

izuzak commented Mar 25, 2019

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
Copy link
Author

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
Copy link
Owner

izuzak commented Mar 27, 2019

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants